equatable_lint_ultimate
This package is based on a fork from the equatable_lint package
This package used the custom_lint package
Table of content
Setup local
- In your
pubspec.yaml
, add thesedev_dependencies
:
dev_dependencies:
custom_lint:
equatable_lint_ultimate:
- In your
analysis_options.yaml
, add this plugin :
analyzer:
plugins:
- custom_lint
# Optional : Disable unwanted rules
custom_lint:
rules:
- always_call_super_props_when_overriding_equatable_props: false
-
Run
flutter pub get
ordart pub get
in your package -
Possibly restart your IDE
Setup CI
flutter analyze
or dart analyze
don't use this custom rule when checking your code
If you want to analyze your code with this rule in your CI, add a step that run flutter pub run custom_lint
or dart run custom_lint
All the lints
missing_field_in_equatable_props
Class extending Equatable should put every field into equatable props
Good:
class MyClass extends Equatable {
const MyClass({this.myField});
final String? myField;
@override
List<Object?> get props => [myField];
}
Bad:
class MyClass extends Equatable {
const MyClass({this.myField});
final String? myField;
@override
List<Object?> get props => [];
}
always_call_super_props_when_overriding_equatable_props
Should always call super when overriding equatable props
Good:
class MyClass extends RandomClassExtendingEquatable {
const MyClass({this.newField});
final String? newField;
@override
List<Object?> get props => super.props..addAll([newField]);
}
Bad:
class MyClass extends RandomClassExtendingEquatable {
const MyClass({this.newField});
final String? newField;
@override
List<Object?> get props => [newField];
}
All the lints fixes
missing_field_in_equatable_props fixes
Add every fields to equatable props
Add field to equatable props
always_call_super_props_when_overriding_equatable_props fixes
Call super in overridden equatable props
All the assists
Make class extend Equatable
About Tomasz Czajka
I am deeply committed to ensuring code quality, which is why I have chosen to adopt these wonderful package (as their original authors are no longer reachable).