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",
"dependenciesAllowed": false
},
{
"filePattern": "*viewmodel.dart",
"exclusiveDependencies": ["*repository.dart"]
},
{
"filePattern": "*repository.dart",
"forbiddenDependencies": ["*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/exclusive_dependencies_rule_checker
- analyzer/checker/forbidden_dependencies_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/analysis_error_info
- model/config_keys
- model/eagle_eye_config
- model/eagle_eye_config_item
- model/exceptions/application_name_not_found_exception
- model/exceptions/config_file_not_found_exception
- model/exceptions/eagle_eye_exception
- model/exceptions/empty_dart_file_list_exception
- model/exceptions/invalid_json_key_exception
- model/exceptions/library_folder_not_found_exception
- util/logger_helper