Skip to content

fxOne/eslint-plugin-sort-keys-shorthand

Repository files navigation

ESLint-plugin-sort-keys-shorthand

Extended short-key rule to handle shorthand properties as ESLint doesn't want to support it

Installation

Install ESLint either locally or globally. (Note that locally, per project, is strongly preferred)

$ npm install eslint --save-dev

If you installed ESLint globally, you have to install React plugin globally too. Otherwise, install it locally.

$ npm install eslint-plugin-sort-keys-shorthand --save-dev

Configuration

Add "sort-keys-shorthand" to the plugins section.

{
  "plugins": ["sort-keys-shorthand"]
}

Deactivate the original sort-keys rule.

{
  "rules": {
    "sort-keys": 0
  }
}

Enable sort-keys-shorthand:

{
  "rules": {
    "sort-keys-shorthand/sort-keys-shorthand": [
      "error",
      "asc",
      {
        "caseSensitive": true,
        "natural": false,
        "minKeys": 2,
        "shorthand": "first"
      }
    ]
  }
}

Rules