clean_arch_lint 3.2.0
clean_arch_lint: ^3.2.0 copied to clipboard
Analyzer plugin that enforces Clean Architecture layer boundaries in Flutter/Dart projects by checking imports and exports.
3.2.0 #
- Features:
- Every rule now checks
exportdirectives like imports (ArchitectureImportRulevisitsExportDirectivetoo). Re-exporting a forbidden library, such asexport 'package:app/data/models/product_model.dart';inpresentation, leaked it to every importer without a warning. Projects with such exports will see new diagnostics. - Feature-first layouts are detected:
lib/features/<feature>/{layer}/andlib/src/features/<feature>/{layer}/(layerOfskipsfeatures/<feature>/). There is no rule between features; imports across features follow the same layer rules. - Monorepos with one package per layer are detected (#30). A package named
<project>_{layer}(my_app_core,my_app_domain,my_app_data,my_app_presentation,my_app_screens) is a layer package: its files outside a layer directory get that layer (packageLayerOf, used bylayerOfas a fallback). Packages with the same<project>prefix, and<project>itself, form one project (isSameProject), somy_app_presentationimportingpackage:my_app_data/...is reported. Packages of other projects (firebase_core,other_data) stay outside the layers.allow_third_party_packages_in_domaindoes not treat sibling layer packages as third-party:my_app_domainimportingmy_app_datastays reported.
- Every rule now checks
- Note: a single-package app whose name ends in a layer suffix (for example
shop_core) is now a layer package, so its files outside layer directories (lib/main.dart,lib/widgets/) get that layer and may see new diagnostics. - Package:
topicsadded topubspec.yaml(lints,analyzer,architecture,clean-architecture,flutter), and the description mentions exports.
3.1.0 #
- Features:
allow_third_party_packages_in_domain: when enabled,domain_only_depends_on_itselfallows third-party packages indomain(AllowThirdPartyPackagesInDomainRule). It reports nothing by itself. Flutter SDK packages,dart:ui,dart:ioand other layers stay reported. Off by default, so third-party packages are still reported unless the option is enabled.
3.0.0 #
- Breaking changes:
no_data_dependenciesnow covers onlypresentation/screensimportingdata.data/coreimportingscreensorpresentationis reported underno_screens_dependencies, which previously never fired. Projects that enabled onlyno_data_dependenciesmust also enableno_screens_dependenciesto keep that check.domain_only_depends_on_itselfallows only pure Dart libraries (dart:core,dart:async,dart:collection,dart:convert,dart:math,dart:typed_data).dart:ui,dart:io,dart:html,dart:ffiand other SDK libraries are now reported indomain(previously everydart:import was allowed, despite the docs sayingdart:uiwas reported).
- Fixes:
- Each diagnostic can be enabled or disabled independently. Previously one
MultiAnalysisRulenamedno_screens_dependenciesserved all three, and the analyzer only runs a rule when the diagnostic matching its name is enabled, so turning offno_screens_dependenciessilenced every check.NoDataDependenciesRule,NoScreensDependenciesRuleandDomainOnlyDependsOnItselfRuleare now registered separately on top of a sharedArchitectureImportRule. - Layers are detected from the analyzer's resolved library URIs
(
ImportDirective.libraryImport/LibraryFragment.source.uri) instead of file-system paths. Relative andpackage:imports resolve identically, and imports from other packages are no longer mistaken for the project's own layers.
- Each diagnostic can be enabled or disabled independently. Previously one
- Removed:
ResolvedImportand the path helpersresolveImport,isInLayer,importsFromLayer,normalizePath,extractPackageName,extractProjectRoot(replaced bylayerOf,packageNameOf,importedUriOf,isPureDartLibrary).- Unused
noPresentationDependenciesCode,isFlutterImport, debugLoggerUtiland thepathdependency.
- Messages: diagnostic messages rewritten.
domain_only_depends_on_itselfno longer says only data and presentation are forbidden, and every correction message now suggests a fix instead of repeating the problem. - Tests: rule tests with
analyzer_testingfor all three diagnostics (replacing placeholder tests). - Docs: troubleshooting note —
dart analyze <directory>skips analyzer plugins (dart-lang/sdk#62710); analyze the package root.
2.0.1 #
- Fix: missing main file
2.0.0 #
- Breaking changes:
- Removed
CoreNoFlutter,CoreNoDataOrPresentation,DataNoPresentation,PresentationNoData,DomainOnly - Removed
NoImportVisitor/OnlyImportVisitor; one import visitor covers all layers - Diagnostics:
no_data_dependencies,no_screens_dependencies,domain_only_depends_on_itself - Enable via the top-level
pluginssection inanalysis_options.yaml - Run
dart analyze/flutter analyze(notdart run custom_lint) - Lint diagnostics are off until listed under
plugins.clean_arch_lint.diagnostics - Added
screensas a first-class layer alongsidecore,domain,data,presentation - Documentation (README, USAGE, RULES, CONTRIBUTING, library dartdoc) updated to the simplified plugin
- Removed
- New features:
- New lint rule to warn when screens depend on data
- Can be configured to ERROR via
analysis_options.yaml - Added comprehensive tests for the rule
- Added example files demonstrating the rule
- Updated documentation (README and USAGE) to reflect the new rule
1.1.0 #
- Feature: Flexible folder structure support
- Now supports both
/lib/{layer}/and/lib/src/{layer}/patterns - Automatic detection - no configuration needed
- Updated
isInLayer()andimportsFromLayer()functions to check both patterns - Added comprehensive tests for both folder structures
- Added example files demonstrating both patterns
- Updated documentation (README and USAGE) to reflect new capability
- Now supports both
1.0.1 #
- Documentation improvements following Dart Effective Documentation guidelines:
- Added comprehensive doc comments to all public APIs
- Enhanced library-level documentation with usage examples
- Improved documentation for all utility functions in
import_resolver.dart - Added detailed examples for each lint rule showing violations and solutions
- Documented parameters, return values, and edge cases
- Added code examples using markdown code blocks with syntax highlighting
- Improved readability with proper formatting and structure
- All documentation now follows Dart conventions:
- Uses
///for doc comments - Starts with summary sentences
- Uses third-person verbs for functions
- Uses noun phrases for properties
- Includes practical code examples
- Uses
[]for identifier references
- Uses
1.0.0 #
- Initial release of clean_arch_lint
- Implements custom lint rules for Flutter Clean Architecture
- Rules:
core_no_flutter: Prevents Flutter/UI imports in core layer (ERROR)core_no_data_or_presentation: Prevents core from depending on data/presentation layers (ERROR)data_no_presentation: Prevents data layer from depending on presentation layer (ERROR)presentation_no_data: Warns when presentation depends directly on data layer (WARNING, configurable to ERROR)
- Utility functions for import resolution and path normalization
- Comprehensive example project demonstrating correct architecture
- Full documentation and usage guide