import_lint
2.0.0, released 7 months ago by kawa.dev
Defines rules to restrict imports and perform static analysis in Dart code.
What it does
The import_lint package enforces custom import restrictions and rules via static analysis and a CLI tool. It integrates with the Dart analysis server to report unauthorized imports directly in your IDE.
AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to enforce architectural boundaries and restrict specific imports between layers or packages.
- You need CLI or IDE warnings for prohibited import paths.
Skip it when
- Your project uses a Dart SDK older than 3.10.0.
- You do not need strict architectural layering rules for imports.
Strengths
- Integrates directly into the IDE via analysis server plugins.
- Provides both CLI support and IDE lint warnings.
- Customizable glob patterns for targets, sources, and exceptions.
Weaknesses
- Requires manual restart of the Dart Analysis Server after updating configuration plugins.
- Strict Dart SDK version requirement (>=3.10.0 <4.0.0).
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 8
Add import_lint as a dev_dependency, configure rules in analysis_options.yaml, and restart the Dart Analysis Server.
plugins:
import_lint: <version number>
import_lint:
rules:
example_rule:
target: "package:example/target/*.dart"
from: "package:example/from/*.dart"
except: ["package:example/from/except.dart"]Alternatives
Packages that do the same job and could replace import_lint.
- lints
Official recommended lints from the Dart team for standard stylistic and correctness rules.
86Compare - flutter_lints
Official recommended lints specifically tailored for Flutter applications.
83Compare
Works with
Packages commonly used together with import_lint: ones it builds on, ones built on it, and its own family.
- analyzerimport_lint depends on itPerforms static analysis of Dart code for tool integration and embedding.
- yamlimport_lint depends on itA Dart library for parsing YAML documents into Dart data structures.
- globimport_lint depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- argsimport_lint depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- cli_utilimport_lint depends on itUtilities to help build Dart command-line apps, find the SDK, and display progress.
- analysis_server_pluginimport_lint depends on itFramework and support code for building plugins for the Dart analysis server.