import_lint 0.1.3 copy "import_lint: ^0.1.3" to clipboard
import_lint: ^0.1.3 copied to clipboard

outdated

The Import Lint package defines import lint rules and report on lints found in Dart code.

cover

Why import lint? #

The Import Lint package defines import lint rules and report on lints found in Dart code.

😻 Usage #

  1. You have lints configured in an import_analysis_options.yaml file at the root of your project.
  • check_file_reg_exp: Specify a files to analyze.(RegExp)
  • not_allow_import_reg_exps: Specify import rules not to allow.(List of RegExp)

Example

rules:
    use_case_rule:
        check_file_reg_exp: ".*use_case.dart"
        not_allow_import_reg_exps: [".*use_case.dart"]
    repository_rule:
        check_file_reg_exp: ".*repository.dart"
        not_allow_import_reg_exps: [".*repository.dart", ".*use_case.dart"]
    custom_rule:
        check_file_reg_exp: ".*custom_search.dart"
        not_allow_import_reg_exps: [".*not_arrow.dart"]
  1. Add import_lint as a dev_dependencies in pubspec.yamls.
dev_dependencies:
    import_lint: ^0.1.3
  1. run import_linter
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:
        check_file_reg_exp: ".*use_case.dart"
        not_allow_import_reg_exps: [".*use_case.dart"]
    repository_rule:
        check_file_reg_exp: ".*repository.dart"
        not_allow_import_reg_exps: [".*repository.dart", ".*use_case.dart"]

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 TestOneUseCase {}

        - test_two_repository.dart
        
            class TestOneRepository {}
    
    - use_case
        - test_one_use_case.dart
        
            class TestOneUseCase {}
        
        - 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 Line
  • Support Directory
  • Add Test
25
likes
0
pub points
89%
popularity

Publisher

verified publisherkawa.dev

The Import Lint package defines import lint rules and report on lints found in Dart code.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

yaml

More

Packages that depend on import_lint