eslint-plugin-sort-keys-custom

2.0.0 • Public • Published

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-dev

Next, install eslint-plugin-sort-keys-custom:

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

Note: 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.

Package Sidebar

Install

npm i eslint-plugin-sort-keys-custom

Weekly Downloads

70

Version

2.0.0

License

ISC

Unpacked Size

95.3 kB

Total Files

8

Last publish

Collaborators

  • elliesec