extend-equatable

Group
Style
Path
lint/style/extend-equatable
Default
Off, opt in
Origin
Falcon
Domain
equatable
Rule
235 of 512
equatable

Require Equatable semantics for configured class/file name patterns. Configure class-name-pattern or file-name-pattern; without either option, this rule reports no diagnostics. Already equatable subtypes (including EquatableMixin users) and unresolved inheritance are conservatively skipped.

Invalid

example.dartdart
import 'package:equatable/equatable.dart';
class FirstState {}
class SecondState {}
abstract class ThirdState {}
class FourthState extends Base {}
class FifthState with Other {}
class Base {}
mixin Other {}
This class matches the configured pattern and should extend `Equatable` or mix in `EquatableMixin`.
1import 'package:equatable/equatable.dart';
2class FirstState {}
This class matches the configured pattern and should extend `Equatable` or mix in `EquatableMixin`.
2class FirstState {}
3class SecondState {}
This class matches the configured pattern and should extend `Equatable` or mix in `EquatableMixin`.
3class SecondState {}
4abstract class ThirdState {}
This class matches the configured pattern and should extend `Equatable` or mix in `EquatableMixin`.
4abstract class ThirdState {}
5class FourthState extends Base {}
This class matches the configured pattern and should extend `Equatable` or mix in `EquatableMixin`.
5class FourthState extends Base {}
6class FifthState with Other {}

Valid

example.dartdart
import 'package:equatable/equatable.dart';
import 'package:equatable/equatable.dart' as eq;
class FirstState extends Equatable {}
class SecondState with EquatableMixin {}
class ThirdState extends FirstState {}
class FourthState extends eq.Equatable {}
class FifthState with eq.EquatableMixin {}
class NotConfigured {}
class UnknownState extends Missing {}
class InterfaceState implements Equatable {}
mixin class ViewState {}

Configure extend-equatable

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "extend-equatable": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/style/extend-equatable: <reason>
  • file-namesfile_namesrecommended

    Enforces lowercase_with_underscores for source file names.

  • flutter-style-todosflutter_style_todos

    Flags TODO comments that do not follow the Flutter style // TODO(username): message, https://URL-to-issue.

  • format-commentformat-comment

    Flags comments that are not formatted as complete sentences.

  • implicit-call-tearoffsimplicit_call_tearoffs

    Explicitly tear off callable objects' call methods.

  • initializers-ordering

    Requires field initializers to follow their containing type's field declaration order by default.

  • leading-newlines-in-multiline-stringsleading_newlines_in_multiline_strings

    Flags a multiline string spanning several lines whose text does not start with a line break right after the opening quotes.

  • library-annotationslibrary_annotationsrecommended

    Requires library-targeted metadata to attach to a library directive.

  • library-nameslibrary_namesrecommended

    Flags a library name that is not lowercase_with_underscores.