Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leo-buneev/eslint-plugin-sort-keys-fix
Fork of https://eslint.org/docs/rules/sort-keys that allows automatic fixing
https://github.com/leo-buneev/eslint-plugin-sort-keys-fix
Last synced: 12 days ago
JSON representation
Fork of https://eslint.org/docs/rules/sort-keys that allows automatic fixing
- Host: GitHub
- URL: https://github.com/leo-buneev/eslint-plugin-sort-keys-fix
- Owner: leo-buneev
- Created: 2018-11-06T23:52:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T01:45:24.000Z (5 months ago)
- Last Synced: 2024-10-13T16:09:10.886Z (26 days ago)
- Language: JavaScript
- Size: 394 KB
- Stars: 97
- Watchers: 2
- Forks: 23
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-eslint - sort-keys-fix - Adds fixer for ESLint `sort-keys` rule. (Plugins / Practices and Specific ES Features)
README
# eslint-plugin-sort-keys-fix
Fork of eslint rule that sorts keys in objects (https://eslint.org/docs/rules/sort-keys) with autofix enabled
## Installation
You'll first need to install [ESLint](http://eslint.org):
```
$ npm i eslint --save-dev
```Next, install `eslint-plugin-sort-keys-fix`:
```
$ npm install eslint-plugin-sort-keys-fix --save-dev
```**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-sort-keys-fix` globally.
## Usage
Add `sort-keys-fix` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
```json
{
"plugins": [
"sort-keys-fix"
]
}
```Then add sort-keys-fix rule under the rules section.
```json
{
"rules": {
"sort-keys-fix/sort-keys-fix": "warn"
}
}
```Often it makes sense to enable `sort-keys-fix` only for certain files/directories. For cases like that, use override key of eslint config:
```jsonc
{
"rules": {
// ...
},
"overrides": [
{
"files": ["src/alphabetical.js", "bin/*.js", "lib/*.js"],
"rules": {
"sort-keys-fix/sort-keys-fix": "warn"
}
}
]
}
```## Rule configuration
For available config options, see [official sort-keys reference](https://eslint.org/docs/rules/sort-keys#require-object-keys-to-be-sorted-sort-keys). All options supported by `sort-keys`, besides `minKeys`, are supported by `sort-keys-fix`.