map-keys-ordering
- Group
- Style
- Path
lint/style/map-keys-ordering- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 258 of 512
Flags literal string map keys 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.
Dynamic keys, spreads, collection control-flow, interpolations, adjacent
strings, and escaped non-raw strings break the comparison sequence.
Invalid
final first = {'zebra': 1, 'apple': 2};
final second = {"red": 1, "blue": 2};
final raw = {r'zebra': 1, r'apple': 2};
final mixedQuotes = {'zebra': 1, "apple": 2};
final nested = {'outer': {'zebra': 1, 'apple': 2}};final first = {'zebra': 1, 'apple': 2};final first = {'zebra': 1, 'apple': 2};final second = {"red": 1, "blue": 2};final second = {"red": 1, "blue": 2};final raw = {r'zebra': 1, r'apple': 2};final raw = {r'zebra': 1, r'apple': 2};final mixedQuotes = {'zebra': 1, "apple": 2};final mixedQuotes = {'zebra': 1, "apple": 2};final nested = {'outer': {'zebra': 1, 'apple': 2}};Valid
final sorted = {'apple': 1, 'zebra': 2};
final singleton = {'zebra': 1};
final numbers = {2: 1, 1: 2};
Map<String, int> withSpread(Map<String, int> other) => {'zebra': 1, ...other, 'apple': 2};
Map<String, int> dynamicKey(String key) => {'zebra': 1, key: 2, 'apple': 3};
Map<String, int> interpolation(String key) => {'zebra': 1, '$key': 2, 'apple': 3};
final escaped = {'zebra': 1, '\u0061pple': 2};
Map<String, int> conditional(bool flag) => {'zebra': 1, if (flag) 'middle': 2, 'apple': 3};
final duplicates = {'apple': 1, 'apple': 2};
final adjacent = {'zebra': 1, 'a' 'pple': 2};Configure map-keys-ordering
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"map-keys-ordering": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/map-keys-ordering: <reason>More style rules
- matching-super-parameters
matching_super_parametersFlags positional super parameters named differently from the super constructor's corresponding parameter.
- member-ordering
member-orderingFlags class members declared out of the configured order.
- missing-whitespace-between-adjacent-strings
missing_whitespace_between_adjacent_stringsrecommendedFlags adjacent string literals that join two words without a space between them.
- newline-before-break
Requires a blank line before a break that follows another statement.
- newline-before-case
Requires a blank line between successive switch statement case clauses.
- newline-before-constructor
Requires a blank line before constructors following another member.
- newline-before-continue
Requires a blank line before a continue that follows another statement.
- newline-before-method
Requires a blank line before method declarations following another member.