eslint plugin which support sorting shorthand keys
npm install eslint-plugin-sort-keys-shorthandExtended short-key rule to handle shorthand properties as ESLint doesn't want to support it
- https://github.com/eslint/eslint/issues/7543
This plugin is compatible with ESLint 9 and above. If you are using ESLint 9+, please use the new flat config format as shown below.
Install ESLint either locally or globally. (Note that locally, per project, is strongly preferred)
``sh`
$ npm install eslint --save-dev
If you installed ESLint globally, you have to install this plugin globally too. Otherwise, install it locally.
`sh`
$ npm install eslint-plugin-sort-keys-shorthand --save-dev
Create an eslint.config.js file in your project root:
`js
import sortKeysShorthand from 'eslint-plugin-sort-keys-shorthand';
export default [
{
plugins: {
'sort-keys-shorthand': sortKeysShorthand
},
rules: {
'sort-keys-shorthand/sort-keys-shorthand': [
'error',
'asc',
{
caseSensitive: true,
minKeys: 2,
natural: false,
shorthand: 'first'
}
]
}
}
];
`
If you are migrating from .eslintrc to flat config, move your plugin and rule configuration as shown above. The old .eslintrc` format is no longer recommended for ESLint 9+.
- sort-keys-shorthand/sort-keys-shorthand: extended rule with shorthand support