import_lint 0.1.6 import_lint: ^0.1.6 copied to clipboard
The Import Lint package defines import lint rules and report on lints found in Dart code.
Why import lint? #
The Import Lint package defines import lint rules and report on lints found in Dart code.
๐ป Usage #
- You have lints configured in an
import_analysis_options.yaml
file at the root of your project.
- search_file_path_reg_exp: Specify a file paths to analyze.(RegExp)
- not_allow_import_reg_exps: Specify import rules not to allow.(List of RegExp)
- not_allow_import_reg_exps: Specify ignore import rules.(List of RegExp)
Example
rules:
use_case_rule:
search_file_path_reg_exp: ".*use_case.dart"
not_allow_import_reg_exps: [".*use_case.dart"]
ignore_import_reg_exps: [".*base_use_case.dart"]
repository_rule:
search_file_path_reg_exp: ".*repository.dart"
not_allow_import_reg_exps: [".*repository.dart", ".*use_case.dart"]
ignore_import_reg_exps: []
custom_rule:
search_file_path_reg_exp: ".*custom_search.dart"
not_allow_import_reg_exps: [".*not_allow.dart"]
ignore_import_reg_exps: [".*ignore.dart"]
- Add import_lint as a dev_dependencies in pubspec.yamls.
dev_dependencies:
import_lint: ^0.1.6
- run import_lint
flutter pub run import_lint
or
dart pub run import_lint
Result #
- Passed
output
No issues found! ๐
- Failed Example
import_analysis_options.yaml
rules:
use_case_rule:
search_file_path_reg_exp: ".*use_case.dart"
not_allow_import_reg_exps: [".*use_case.dart"]
ignore_import_reg_exps: [".*base_use_case.dart"]
repository_rule:
search_file_path_reg_exp: ".*repository.dart"
not_allow_import_reg_exps: [".*repository.dart", ".*use_case.dart"]
ignore_import_reg_exps: []
files
- lib
- repository
- test_one_repository.dart
import 'package:import_analyzer_test/repository/test_two_repository.dart';
import 'package:import_analyzer_test/use_case/test_one_use_case.dart';
class TestOneRepository {}
- test_two_repository.dart
class TestTwoRepository {}
- use_case
- test_one_use_case.dart
import 'package:import_analyzer_test/use_case/base_use_case.dart';
class TestOneUseCase extends BaseUseCase {}
- test_two_use_case.dart
import 'package:import_analyzer_test/repository/test_one_repository.dart';
import 'package:import_analyzer_test/use_case/test_one_use_case.dart';
class TestTwoUseCase {}
output
use_case_rule โข package:import_analyzer_test/use_case/test_two_use_case.dart โข import 'package:import_analyzer_test/use_case/test_one_use_case.dart':2
repository_rule โข package:import_analyzer_test/repository/test_one_repository.dart โข import 'package:import_analyzer_test/repository/test_two_repository.dart':1
repository_rule โข package:import_analyzer_test/repository/test_one_repository.dart โข import 'package:import_analyzer_test/use_case/test_one_use_case.dart':2
๐งค Features #
- โ Analyze import
- โ Support RegExp
- โ Ignore File
- โ Ignore Line
- โ Support Directory
- โ Add Test