list-all-equatable-fields

Path
lint/correctness/list-all-equatable-fields
Default
On (recommended)
Origin
Falcon
Domain
equatable
Rule
256 of 512
recommendedequatable

Flags declared instance fields omitted from a statically understood Equatable props list.

Only resolved transitive package:equatable Equatable/EquatableMixin subtypes inheriting Equatable's concrete equality are checked; classes replacing equality are excluded. Instance storage includes private and primary-constructor fields, but not static, abstract or external fields or computed getters. Arrow getters and single-return blocks with literal lists are supported, including this.field, super.props spreads and cascaded addAll calls with known lists. Unknown expressions, collection control flow, and unknown spreads are left silent.

Invalid

example.dartdart
import 'package:equatable/equatable.dart';
import 'package:equatable/equatable.dart' as eq;
import 'support.dart';
class Direct extends Equatable {
  final int value = 1;
  List<Object?> get props => [];
}
class MixedValue with EquatableMixin {
  final int value = 1;
  List<Object?> get props => [];
}
class Indirect extends Middle {
  final int child = 1;
  List<Object?> get props => [...super.props];
}
class Prefixed extends eq.Equatable {
  final int x = 1, y = 2;
  List<Object?> get props => [x];
}
class Private extends Mixed {
  final int _value = 1;
  List<Object?> get props { return []; }
}
class Cascaded extends Parent {
  final int value = 1;
  List<Object?> get props => super.props..addAll([]);
}
The `props` list omits declared instance fields. Add every field to the list.
5 final int value = 1;
6 List<Object?> get props => [];
The `props` list omits declared instance fields. Add every field to the list.
9 final int value = 1;
10 List<Object?> get props => [];
The `props` list omits declared instance fields. Add every field to the list.
13 final int child = 1;
14 List<Object?> get props => [...super.props];
The `props` list omits declared instance fields. Add every field to the list.
17 final int x = 1, y = 2;
18 List<Object?> get props => [x];
The `props` list omits declared instance fields. Add every field to the list.
21 final int _value = 1;
22 List<Object?> get props { return []; }
The `props` list omits declared instance fields. Add every field to the list.
25 final int value = 1;
26 List<Object?> get props => super.props..addAll([]);

Valid

example.dartdart
import 'package:equatable/equatable.dart';
import 'support.dart';
class Complete extends Equatable {
  final int value = 1;
  List<Object?> get props => [value];
}
class ExplicitThis with EquatableMixin {
  final int value = 1;
  List<Object?> get props { return [this.value]; }
}
class StaticOnly extends Parent {
  static int ignored = 1;
  int get computed => 2;
  List<Object?> get props => [...super.props];
}
class UnknownCall extends Parent {
  final int value = 1;
  List<Object?> values() => [value];
  List<Object?> get props => values();
}
class UnknownSpread extends Parent {
  final int value = 1;
  List<Object?> values() => [value];
  List<Object?> get props => [...values()];
}
class Conditional extends Parent {
  final int value = 1;
  List<Object?> get props => [if (true) value];
}
class CompleteChild extends Middle {
  final int child = 1;
  List<Object?> get props => [...super.props, child];
}
class Unrelated {
  final int value = 1;
  List<Object?> get props => [];
}
class Cascaded extends Parent {
  final int value = 1;
  List<Object?> get props => super.props..addAll([value]);
}
class UnknownCascade extends Parent {
  final int value = 1;
  List<Object?> values() => [value];
  List<Object?> get props => super.props..addAll(values());
}

Configure list-all-equatable-fields

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

falcon.jsonjson
{
  "linter": {
    "rules": {
      "correctness": {
        "list-all-equatable-fields": "error"
      }
    }
  }
}

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

example.dartdart
// falcon-ignore lint/correctness/list-all-equatable-fields: <reason>
  • literal-only-boolean-expressionsliteral_only_boolean_expressionsrecommended

    Flags conditions built only from literals, whose value never changes.

  • match-getter-setter-field-names

    Detect likely copy-paste errors in trivial accessors when a different field matching the accessor name is declared.

  • missing-test-assertionrecommendedtest

    Reports inline test callbacks that contain no recognized assertion calls.

  • no-adjacent-strings-in-listno_adjacent_strings_in_listrecommended

    Flags adjacent string literals used as an element of a list or set literal.

  • no-import-cyclescross-file

    Report mutually dependent components of imported or exported library files.

  • no-logic-in-create-stateno_logic_in_create_staterecommendedflutter

    Require StatefulWidget.createState to return only a fresh zero-argument Flutter State construction.

  • no-self-assignmentsno_self_assignmentsrecommended

    Flags assignments of a variable to itself, such as x = x;.

  • null-check-on-nullable-type-parameternull_check_on_nullable_type_parameterrecommended

    Flags a null assertion x! on a nullable type parameter T? whose expected type is T or T? for a potentially nullable T, and null-assert patterns whose matched value is a nullable type parameter.