parameters-ordering

Group
Style
Path
lint/style/parameters-ordering
Default
Off, opt in
Origin
Falcon
Rule
309 of 512

Requires named parameters to follow the explicitly configured alphabetical order. Positional parameters are excluded. Set order to ascending or descending; without a valid order this rule does nothing.

Invalid

example.dartdart
void top({int zebra = 0, int  alpha = 0}) {}

class Example {
  Example({int zebra = 0, int  alpha = 0});
  void method({int zebra = 0, int  alpha = 0}) {}
}

void closures() {
  final callback = ({int zebra = 0, int  alpha = 0}) {};
  void local({int zebra = 0, int  alpha = 0}) {}
}

typedef Callback = void Function({int zebra, int  alpha});
Reorder named entries to follow the configured order.
1void top({int zebra = 0, int alpha = 0}) {}
Reorder named entries to follow the configured order.
3class Example {
4 Example({int zebra = 0, int alpha = 0});
Reorder named entries to follow the configured order.
4 Example({int zebra = 0, int alpha = 0});
5 void method({int zebra = 0, int alpha = 0}) {}
Reorder named entries to follow the configured order.
8void closures() {
9 final callback = ({int zebra = 0, int alpha = 0}) {};
Reorder named entries to follow the configured order.
9 final callback = ({int zebra = 0, int alpha = 0}) {};
10 void local({int zebra = 0, int alpha = 0}) {}
Reorder named entries to follow the configured order.
12
13typedef Callback = void Function({int zebra, int alpha});

Valid

example.dartdart
void named({int alpha = 0, int zebra = 0}) {}
void positional(int zebra, int alpha) {}
void optional([int zebra = 0, int alpha = 0]) {}
void mixed(int zebra, int alpha, {int beta = 0, int gamma = 0}) {}
void single({int zebra = 0}) {}

class Example {
  final int alpha;
  final int zebra;
  Example({this.alpha = 0, this.zebra = 0});
}

typedef Callback = void Function({int alpha, int zebra});

Configure parameters-ordering

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

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

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

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