record-fields-ordering

Group
Style
Path
lint/style/record-fields-ordering
Default
Off, opt in
Origin
Falcon
Rule
428 of 512

Flags named record type fields that violate the configured order.

Set order to "ascending" or "descending" for case-sensitive lexicographic ordering. Without a valid explicit order, this rule is inactive. Named fields are checked independently for each record type. Positional fields and record literals are ignored; reordering literal expressions can change effects.

Invalid

example.dartdart
typedef First = ({int zebra, int apple});
typedef Mixed = (int, {int zebra, int apple});
typedef Nested = ({({int zebra, int apple}) outer});
({int zebra, int apple}) typed = (apple: 1, zebra: 2);
typedef Named = ({int zebra, int apple});
Reorder named entries to follow the configured order.
1typedef First = ({int zebra, int apple});
Reorder named entries to follow the configured order.
1typedef First = ({int zebra, int apple});
2typedef Mixed = (int, {int zebra, int apple});
Reorder named entries to follow the configured order.
2typedef Mixed = (int, {int zebra, int apple});
3typedef Nested = ({({int zebra, int apple}) outer});
Reorder named entries to follow the configured order.
3typedef Nested = ({({int zebra, int apple}) outer});
4({int zebra, int apple}) typed = (apple: 1, zebra: 2);
Reorder named entries to follow the configured order.
4({int zebra, int apple}) typed = (apple: 1, zebra: 2);
5typedef Named = ({int zebra, int apple});

Valid

example.dartdart
typedef Sorted = ({int apple, int zebra});
typedef Positional = (String, String);
typedef Mixed = (int, {int apple, int zebra});
typedef Singleton = ({int zebra});
({int apple, int zebra}) typed = (apple: 1, zebra: 2);
typedef Named = ({int apple, int zebra});
final unsortedLiteral = (zebra: 1, apple: 2);

Configure record-fields-ordering

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

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "record-fields-ordering": "error"
      }
    }
  }
}

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

example.dartdart
// falcon-ignore lint/style/record-fields-ordering: <reason>