Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/eslint-10-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"eslint-plugin-sort-keys-shorthand": major
---

Add ESLint 10 support. This is a breaking change — ESLint 9 is no longer supported.

- Replace deprecated `context.getSourceCode()` with `context.sourceCode` (fixes #96)
- Update peer dependency to `eslint ^10.0.0`
- Update all dev dependencies to latest versions
22 changes: 0 additions & 22 deletions .github/workflows/dependabot-auto-merge.yml

This file was deleted.

42 changes: 27 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
name: Release

on: workflow_dispatch
on:
push:
tags:
- "v*"

permissions:
contents: write
id-token: write

jobs:
release:
name: Release
name: Publish to npm
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 20.x
- name: Setup Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
registry-url: "https://registry.npmjs.org"

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Install Dependencies
run: yarn
run: pnpm install

- name: Run Tests
run: pnpm test

- name: Publish to npm (trusted publishing)
run: npm publish --access public

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@master
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
publish: yarn release
commit: 'chore(release): update monorepo packages versions'
title: 'Upcoming Release Changes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
generate_release_notes: true
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Cache node_modules
id: cache-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('yarn.lock') }}
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('pnpm-lock.yaml') }}

- name: Install Dependencies
run: yarn
run: pnpm install

- name: Tests
run: yarn test
run: pnpm test
31 changes: 12 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
# ESLint-plugin-sort-keys-shorthand

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

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

# ESLint 9+ Support
## Requirements

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

# Installation
> **Note:** For ESLint 9 support, use [v3.x](https://github.com/fxOne/eslint-plugin-sort-keys-shorthand/tree/v3.0.0).

Install [ESLint](https://www.github.com/eslint/eslint) either locally or globally. (Note that locally, per project, is strongly preferred)
## Installation

```sh
$ npm install eslint --save-dev
npm install eslint-plugin-sort-keys-shorthand --save-dev
```

If you installed `ESLint` globally, you have to install this plugin globally too. Otherwise, install it locally.
## Configuration

```sh
$ npm install eslint-plugin-sort-keys-shorthand --save-dev
```

# Configuration (ESLint 9+ Flat Config Example)

Create an `eslint.config.js` file in your project root:
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:

```js
import sortKeysShorthand from 'eslint-plugin-sort-keys-shorthand';
Expand All @@ -50,10 +45,8 @@ export default [
];
```

# Migration from .eslintrc

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+.

# Rules
## Rules

- [sort-keys-shorthand/sort-keys-shorthand](docs/rules/sort-keys-shorthand.md): extended rule with shorthand support

Pushing a `v*` tag triggers the release workflow, which runs tests, publishes to npm with provenance, and creates a GitHub Release.
2 changes: 1 addition & 1 deletion lib/rules/sort-keys-shorthand.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ module.exports = {
suggest: [{
desc: 'Fix order',
fix(fixer) {
const sourceCode = context.getSourceCode();
const sourceCode = context.sourceCode;
return fixer.replaceTextRange(
[lastNode.range[0], node.range[1]],
`${sourceCode.text.slice(node.range[0], node.range[1])},${sourceCode.text.slice(lastNode.range[0], lastNode.range[1])}`
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-sort-keys-shorthand",
"version": "3.0.0",
"version": "4.0.0",
"description": "eslint plugin which support sorting shorthand keys",
"main": "index.js",
"scripts": {
Expand All @@ -11,16 +11,16 @@
"eslint"
],
"peerDependencies": {
"eslint": "^9.0.0"
"eslint": "^10.0.0"
},
"author": "Dominic Buetow",
"license": "MIT",
"devDependencies": {
"@changesets/cli": "^2.27.1",
"eslint": "^9.29.0",
"eslint-plugin-import": "^2.31.0",
"@changesets/cli": "^2.30.0",
"eslint": "^10.0.3",
"eslint-plugin-import": "^2.32.0",
"istanbul": "^0.4.5",
"mocha": "11.7.0"
"mocha": "11.7.5"
},
"dependencies": {
"natural-compare": "^1.4.0"
Expand Down
Loading
Loading