y_lints 0.0.8
y_lints: ^0.0.8 copied to clipboard
Custom lint rules that enforce clean architecture boundaries (domain, data, presentation) in Dart and Flutter projects.
Changelog #
0.0.8 #
- New rule
listener_leak: everyaddListener/addObservercall in a class that definesdispose()/close()must be paired with a matchingremoveListener/removeObserverin the lifecycle method (same receiver, same callback identifier). Inline-closure listeners are reported under a separatelistener_leak_closurediagnostic — they can't be removed since each call creates a newFunctioninstance. - New rule
domain_entity_immutable_fields: instance fields on@DomainEntityclasses must befinal(orconst).staticfields are exempt;latealone is not enough — uselate final.
0.0.7 #
-
New rule
dispose_leak: flags disposable fields (TextEditingController,ScrollController,AnimationController,PageController,TabController,FocusNode,ChangeNotifier,ValueNotifier,StreamController,StreamSubscription,Timer) that are not cleaned up in the class'sdispose()/close()method. Runs against the resolved element model and follows the supertype chain, so subclasses of Flutter controllers are also tracked. -
cubit_constructor_dependenciesflipped from a whitelist to a blacklist: only@DataSource/@RemoteDataSource/@MockDataSourceclasses are rejected (including when nested insideFuture<…>,List<…>, etc.). Repositories, value objects, services, primitives, enums, and the user's own classes are all allowed. -
repository_returns_entityonly checks return types again. Parameter types are unconstrained — filter/query objects, request DTOs, and other non-Entitytypes are allowed on the input side (matches thedatasource_returns_modelbehavior from 0.0.4). -
Breaking: renamed lint IDs for consistency with the
datasource_*prefix used elsewhere:data_source_location/data_source_filename→datasource_location/datasource_filenameremote_data_source_location/remote_data_source_filename→remote_datasource_location/remote_datasource_filenamemock_data_source_location/mock_data_source_filename→mock_datasource_location/mock_datasource_filename
Update any
analysis_options.yamlentries that reference the old identifiers.
0.0.6 #
-
Layer roots are now configurable via a
y_lintsblock inanalysis_options.yaml:custom_lint: rules: - y_lints: root: lib/ domain: domain/ data: data/ presentation: presentation/All four fields are optional; defaults match the prior hard-coded layout. Intra-layer folder names (
entities/,datasources/,cubits/, …) and file conventions remain fixed. -
Removed
datasource_import_boundaryrule. Datasources are no longer gated by importer path — teams that need an import boundary can enforce it through their own lint rules or code review.
0.0.5 #
- Type and annotation classification across every rule now runs against
the resolved element model instead of name/suffix matching. Enums,
generic type parameters,
dart:corevalue types, async/collection wrappers, and annotated classes are each recognized through the analyzer element API; a class calledFooEntitythat never declared@DomainEntityno longer satisfies boundary checks, and same-named annotations from unrelated packages no longer trip architectural rules. repository_returns_entitychecks parameters again — now without false positives on enum parameters (Gender,*Filter,*SortOrder, …).datasource_returns_modelaccepts enum return types.cubit_constructor_dependenciesrequires real@Repository/@DomainEntityannotations on injected types; it no longer lets*Repository-suffixed infrastructure through.feature_builder_must_be_widgetresolves the superclass and verifies it originates frompackage:flutter/— local stubs namedStatelessWidget/StatefulWidgetare rejected.model_extends_entityresolves the superclass element and requires@DomainEntityon it (theEntityname suffix is no longer sufficient).datasource_contract_implementedno longer uses the path/filename fallback — classes must carry@RemoteDataSourceor@MockDataSourceto be checked, and the contract must carry@DataSource.
0.0.4 #
repository_returns_entityanddatasource_returns_modelnow only check method return types. Parameter types are unconstrained — filter/query objects, request DTOs, auth tokens, and other non-Entity/Modeltypes no longer trigger the rule.
0.0.3 #
class_suffix_conventionnow accepts bothDataSourceandDatasourcesuffixes for classes underlib/data/datasources/.datasource_contract_implementedrecognizes concrete datasources whose names end with eitherDataSourceorDatasource.domain_entity_puritynow enforces named-only constructor parameters on@DomainEntityclasses (newdomain_entity_named_parametersdiagnostic). Both named required and named optional parameters are accepted; positional parameters are rejected.
0.0.2 #
- Add
@Pageannotation +page_purityrule: enforcesPagesuffix. Location and superclass are not constrained. - Add
@FeatureBuilderannotation +feature_builder_purityrule: enforces location underlib/presentation/<feature>/view/,Buildersuffix, andStatelessWidget/StatefulWidgetextension.
0.0.1 #
- Initial release.
- Architectural lint rules for domain, data, and presentation layers:
domain_entity_purity,repository_purity,repository_impl_puritydata_source_purity,remote_data_source_purity,mock_data_source_puritymodel_purity,datasource_returns_model,repository_returns_entityfeature_cubit_purity,feature_state_puritydatasource_import_boundary,datasource_contract_implementedcubit_constructor_dependencies,class_suffix_convention,required_annotation
- Annotations:
@DomainEntity,@Repository,@RepositoryImpl,@DataSource,@RemoteDataSource,@MockDataSource,@Model,@FeatureCubit,@FeatureState.