Skip to content

Commit c26e3a1

Browse files
authored
v4.0.0 — ESLint 10 support (#97)
* feat!: add ESLint 10 support, migrate to pnpm BREAKING CHANGE: ESLint 9 is no longer supported. Requires ESLint ^10.0.0. - Replace deprecated context.getSourceCode() with context.sourceCode (fixes #96) - Update peer dependency to eslint ^10.0.0 - Update all dev dependencies to latest versions - Migrate from yarn to pnpm - Update CI workflows to use pnpm
1 parent da9c35b commit c26e3a1

File tree

9 files changed

+3189
-2885
lines changed

9 files changed

+3189
-2885
lines changed

.changeset/eslint-10-support.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"eslint-plugin-sort-keys-shorthand": major
3+
---
4+
5+
Add ESLint 10 support. This is a breaking change — ESLint 9 is no longer supported.
6+
7+
- Replace deprecated `context.getSourceCode()` with `context.sourceCode` (fixes #96)
8+
- Update peer dependency to `eslint ^10.0.0`
9+
- Update all dev dependencies to latest versions

.github/workflows/dependabot-auto-merge.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,45 @@
11
name: Release
22

3-
on: workflow_dispatch
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
id-token: write
411

512
jobs:
613
release:
7-
name: Release
14+
name: Publish to npm
815
runs-on: ubuntu-latest
916
steps:
1017
- name: Checkout Repo
1118
uses: actions/checkout@v4
1219
with:
13-
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
1420
fetch-depth: 0
1521

16-
- name: Setup Node.js 20.x
22+
- name: Setup Node.js 22.x
1723
uses: actions/setup-node@v4
1824
with:
19-
node-version: 20.x
25+
node-version: 22.x
26+
registry-url: "https://registry.npmjs.org"
27+
28+
- name: Install pnpm
29+
uses: pnpm/action-setup@v4
30+
with:
31+
version: 10
2032

2133
- name: Install Dependencies
22-
run: yarn
34+
run: pnpm install
35+
36+
- name: Run Tests
37+
run: pnpm test
38+
39+
- name: Publish to npm (trusted publishing)
40+
run: npm publish --access public
2341

24-
- name: Create Release Pull Request or Publish to npm
25-
id: changesets
26-
uses: changesets/action@master
42+
- name: Create GitHub Release
43+
uses: softprops/action-gh-release@v2
2744
with:
28-
publish: yarn release
29-
commit: 'chore(release): update monorepo packages versions'
30-
title: 'Upcoming Release Changes'
31-
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,20 @@ jobs:
2626
with:
2727
node-version: ${{ matrix.node-version }}
2828

29+
- name: Install pnpm
30+
uses: pnpm/action-setup@v4
31+
with:
32+
version: 10
33+
2934
- name: Cache node_modules
3035
id: cache-modules
3136
uses: actions/cache@v4
3237
with:
3338
path: node_modules
34-
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('yarn.lock') }}
39+
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('pnpm-lock.yaml') }}
3540

3641
- name: Install Dependencies
37-
run: yarn
42+
run: pnpm install
3843

3944
- name: Tests
40-
run: yarn test
45+
run: pnpm test

README.md

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
# ESLint-plugin-sort-keys-shorthand
22

3-
Extended short-key rule to handle shorthand properties as ESLint doesn't want to support it
3+
Extended sort-keys rule with shorthand property support, since ESLint doesn't want to support it natively.
44

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

7-
# ESLint 9+ Support
7+
## Requirements
88

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.
9+
- **ESLint 10+**
10+
- **Node.js 20+**
1011

11-
# Installation
12+
> **Note:** For ESLint 9 support, use [v3.x](https://github.com/fxOne/eslint-plugin-sort-keys-shorthand/tree/v3.0.0).
1213
13-
Install [ESLint](https://www.github.com/eslint/eslint) either locally or globally. (Note that locally, per project, is strongly preferred)
14+
## Installation
1415

1516
```sh
16-
$ npm install eslint --save-dev
17+
npm install eslint-plugin-sort-keys-shorthand --save-dev
1718
```
1819

19-
If you installed `ESLint` globally, you have to install this plugin globally too. Otherwise, install it locally.
20+
## Configuration
2021

21-
```sh
22-
$ npm install eslint-plugin-sort-keys-shorthand --save-dev
23-
```
24-
25-
# Configuration (ESLint 9+ Flat Config Example)
26-
27-
Create an `eslint.config.js` file in your project root:
22+
This plugin uses the ESLint [flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) format. Create an `eslint.config.js` in your project root:
2823

2924
```js
3025
import sortKeysShorthand from 'eslint-plugin-sort-keys-shorthand';
@@ -50,10 +45,8 @@ export default [
5045
];
5146
```
5247

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+.
56-
57-
# Rules
48+
## Rules
5849

5950
- [sort-keys-shorthand/sort-keys-shorthand](docs/rules/sort-keys-shorthand.md): extended rule with shorthand support
51+
52+
Pushing a `v*` tag triggers the release workflow, which runs tests, publishes to npm with provenance, and creates a GitHub Release.

lib/rules/sort-keys-shorthand.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ module.exports = {
286286
suggest: [{
287287
desc: 'Fix order',
288288
fix(fixer) {
289-
const sourceCode = context.getSourceCode();
289+
const sourceCode = context.sourceCode;
290290
return fixer.replaceTextRange(
291291
[lastNode.range[0], node.range[1]],
292292
`${sourceCode.text.slice(node.range[0], node.range[1])},${sourceCode.text.slice(lastNode.range[0], lastNode.range[1])}`

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-sort-keys-shorthand",
3-
"version": "3.0.0",
3+
"version": "4.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": "^9.0.0"
14+
"eslint": "^10.0.0"
1515
},
1616
"author": "Dominic Buetow",
1717
"license": "MIT",
1818
"devDependencies": {
19-
"@changesets/cli": "^2.27.1",
20-
"eslint": "^9.29.0",
21-
"eslint-plugin-import": "^2.31.0",
19+
"@changesets/cli": "^2.30.0",
20+
"eslint": "^10.0.3",
21+
"eslint-plugin-import": "^2.32.0",
2222
"istanbul": "^0.4.5",
23-
"mocha": "11.7.0"
23+
"mocha": "11.7.5"
2424
},
2525
"dependencies": {
2626
"natural-compare": "^1.4.0"

0 commit comments

Comments
 (0)