eslint-plugin-sort-keys-custom v2.0.0
eslint-plugin-sort-keys-custom
An ESLint rule that allows a customised sort order to be specified for object keys with an autofix available. Forked from eslint-plugin-sort-keys-fix.
Installation
You'll first need to install ESLint:
$ npm i eslint --save-devNext, install eslint-plugin-sort-keys-custom:
$ npm install eslint-plugin-sort-keys-custom --save-devNote: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-sort-keys-custom globally.
Usage
Add sort-keys-custom to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
{
"plugins": ["sort-keys-custom"]
}Then add sort-keys-custom rule under the rules section.
{
"rules": {
"sort-keys-custom/sort-keys-custom": "warn"
}
}Often it makes sense to enable sort-keys-custom only for certain files/directories. For cases like that, use override key of eslint config:
{
"rules": {
// ...
},
"overrides": [
{
"files": ["src/alphabetical.js", "bin/*.js", "lib/*.js"],
"rules": {
"sort-keys-custom/sort-keys-custom": "warn"
}
}
]
}Rule configuration
For available config options, see official sort-keys reference. All options supported by sort-keys, besides minKeys, are supported by sort-keys-custom.