EagleEye
EagleEye is a Dart CLI tool for detecting architecture violations in Dart projects.
📚 Check our documentation here.
Features
- Analyze Dart project files for architectural rules.
- Detect forbidden dependencies based on configurable patterns.
- Lightweight CLI, easy to integrate into your project workflow.
How to install?
dev_dependencies:
...
eagle_eye: ^version
How to use?
1. Make sure you have a lint rule to avoid relative imports
# analysis_options.yaml
analyzer:
errors:
avoid_relative_lib_imports: error
In this way, we are forcing the internal imports to have the app name:
// BAD ❌ (relative import)
import '../utils/helper.dart';
// GOOD ✅ (package import)
import 'package:my_app/utils/helper.dart';
Ensure that this lint rule is enabled for EagleEye to function correctly.
2. In your project create a file eagle_eye_config.json
Create a JSON file in your project to define rules. Example:
[
{
"filePattern": "*util.dart",
"noDependsEnabled": true
},
{
"filePattern": "*viewmodel.dart",
"justWithPatterns": ["*repository.dart"]
},
{
"filePattern": "*repository.dart",
"doNotWithPatterns": ["*screen.dart"]
}
]
Add the json file in the root level of your project.
Just to explain, we are defining some rules in this example:
-
Any file ending with the
util.dartsuffix must not have dependencies; -
Any viewModel file should depend on repository classes;
-
Any repository file should not depends on screen files.
3. Run the eagle eye locally
dart run eagle_eye:main
If you have any error, the process will fail immediately.
⚠ We are working on error reports.
Libraries
- analyzer/checker/do_not_with_rule_checker
- analyzer/checker/just_with_rule_checker
- analyzer/eagle_eye_matcher
- analyzer/eagle_eye_visitor
- analyzer/regex_helper
- data/eagle_eye_repository
- data/file_helper
- data/json_converter
- eagle_eye_launcher
- model/eagle_eye_config
- model/eagle_eye_config_item
- model/error_info
- util/logger_helper