sort-keys
UnreleasedConfiguration
rslint.config.ts
Rule Details
This rule checks all property definitions of object literal expressions and verifies that all keys are sorted alphabetically.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Examples of incorrect code for this rule with { "caseSensitive": false }:
Examples of incorrect code for this rule with { "natural": true }:
Examples of incorrect code for this rule with { "minKeys": 4 }:
Examples of correct code for this rule with { "allowLineSeparatedGroups": true }:
Examples of correct code for this rule with { "ignoreComputedKeys": true }:
Options
The 1st option is "asc" or "desc".
"asc"(default) enforces properties to be in ascending order."desc"enforces properties to be in descending order.
The 2nd option is an object with the following properties.
caseSensitive— iftrue, enforces properties to be in case-sensitive order. Default istrue.natural— iftrue, enforces properties to be in natural order: strings that mix letters and numbers are compared the way a human would, so10sorts after2instead of before it. Default isfalse.minKeys— the minimum number of keys an object must have for its sort order to be checked. Default is2.allowLineSeparatedGroups— iftrue, a blank line after a property resets sorting: the properties that follow only need to be sorted relative to each other, not to the properties before the blank line. Default isfalse.ignoreComputedKeys— iftrue, computed keys are ignored entirely and reset the sorting of the keys that follow them. Default isfalse.