Skip to content

Commit 8e10552

Browse files
committed
update to eslint 9
1 parent 8ca5a80 commit 8e10552

File tree

5 files changed

+1636
-572
lines changed

5 files changed

+1636
-572
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## To Be Released
77

8+
## 3.0.0
9+
10+
- Update to eslint 9
11+
812
## 2.3.0
913

1014
- Add support for suggestions

README.md

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Extended short-key rule to handle shorthand properties as ESLint doesn't want to
44

55
- https://github.com/eslint/eslint/issues/7543
66

7+
# ESLint 9+ Support
8+
9+
This plugin is compatible with **ESLint 9 and above**. If you are using ESLint 9+, please use the new [flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) format as shown below.
10+
711
# Installation
812

913
Install [ESLint](https://www.github.com/eslint/eslint) either locally or globally. (Note that locally, per project, is strongly preferred)
@@ -12,50 +16,43 @@ Install [ESLint](https://www.github.com/eslint/eslint) either locally or globall
1216
$ npm install eslint --save-dev
1317
```
1418

15-
If you installed `ESLint` globally, you have to install React plugin globally too. Otherwise, install it locally.
19+
If you installed `ESLint` globally, you have to install this plugin globally too. Otherwise, install it locally.
1620

1721
```sh
1822
$ npm install eslint-plugin-sort-keys-shorthand --save-dev
1923
```
2024

21-
# Configuration
22-
23-
Add "sort-keys-shorthand" to the plugins section.
24-
25-
```json
26-
{
27-
"plugins": ["sort-keys-shorthand"]
28-
}
29-
```
30-
31-
Deactivate the original `sort-keys` rule.
32-
33-
```json
34-
{
35-
"rules": {
36-
"sort-keys": 0
25+
# Configuration (ESLint 9+ Flat Config Example)
26+
27+
Create an `eslint.config.js` file in your project root:
28+
29+
```js
30+
import sortKeysShorthand from 'eslint-plugin-sort-keys-shorthand';
31+
32+
export default [
33+
{
34+
plugins: {
35+
'sort-keys-shorthand': sortKeysShorthand
36+
},
37+
rules: {
38+
'sort-keys-shorthand/sort-keys-shorthand': [
39+
'error',
40+
'asc',
41+
{
42+
caseSensitive: true,
43+
minKeys: 2,
44+
natural: false,
45+
shorthand: 'first'
46+
}
47+
]
48+
}
3749
}
38-
}
50+
];
3951
```
4052

41-
Enable `sort-keys-shorthand`:
42-
43-
```json
44-
{
45-
"rules": {
46-
"sort-keys-shorthand/sort-keys-shorthand": [
47-
"error",
48-
"asc",
49-
{
50-
"caseSensitive": true,
51-
"minKeys": 2,
52-
"natural": false,
53-
"shorthand": "first"
54-
}
55-
]
56-
}
57-
}
58-
```
53+
# Migration from .eslintrc
54+
55+
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+.
5956

6057
# Rules
6158

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-sort-keys-shorthand",
3-
"version": "2.3.0",
3+
"version": "3.0.0",
44
"description": "eslint plugin which support sorting shorthand keys",
55
"main": "index.js",
66
"scripts": {
@@ -11,16 +11,16 @@
1111
"eslint"
1212
],
1313
"peerDependencies": {
14-
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
14+
"eslint": "^9.0.0"
1515
},
1616
"author": "Dominic Buetow",
1717
"license": "MIT",
1818
"devDependencies": {
1919
"@changesets/cli": "^2.27.1",
20-
"eslint": "^8",
21-
"eslint-plugin-import": "^2.29.1",
20+
"eslint": "^9.29.0",
21+
"eslint-plugin-import": "^2.31.0",
2222
"istanbul": "^0.4.5",
23-
"mocha": "10.4.0"
23+
"mocha": "11.7.0"
2424
},
2525
"dependencies": {
2626
"natural-compare": "^1.4.0"

0 commit comments

Comments
 (0)