Rule: object-literal-sort-keys

Checks ordering of keys in object literals.

Rationale

Useful in preventing merge conflicts

Config

By default, this rule checks that keys are in alphabetical order. The following may optionally be passed:

  • “ignore-case” will to compare keys in a case insensitive way.
  • “match-declaration-order will prefer to use the key ordering of the contextual type of the object literal, as in:

    interface I { foo: number; bar: number; } const obj: I = { foo: 1, bar: 2 };

If a contextual type is not found, alphabetical ordering will be used instead.

Examples
"object-literal-sort-keys": true
"object-literal-sort-keys": [true, "ignore-case", "match-declaration-order"]
Schema
{
  "type": "string",
  "enum": [
    "ignore-case",
    "match-declaration-order"
  ]
}