eslint / eslint/json

Bug: `sort-keys` autofix requires multiple passes

Open
#222 7 comments 1 reaction 1 assignee Claimed by @crimsonjay0 View on GitHub
accepted bug
Dominant language
JavaScript
Stars
121
Forks
30
Avg merge
2d 5h
Merged PRs (30d)
6

Description

### Environment

ESLint version: 10.0.3
@eslint/json version: 1.2.0
Node version: 24.14.0
npm version: 11.9.0
Operating System: darwin 25.3.0

### Which language are you using?

json

### What did you do?

Configuration

```
import config from "@easyjet-dev/eslint-config";
import { defineConfig } from "eslint/config";

export default defineConfig([{ extends: [config] }]);
```

```js
import { includeIgnoreFile } from "@eslint/compat";
import javascript from "@eslint/js";
import json from "@eslint/json";
import { defineConfig } from "eslint/config";
import turbo from "eslint-config-turbo/flat";
import prettierRecommended from "eslint-plugin-prettier/recommended";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import { findUp } from "find-up";
import typescript from "typescript-eslint";

/** @type {import("@eslint/config-helpers").ConfigWithExtendsArray} */
const configs = [
{
ignores: ["!.github", "!.storybook"],
languageOptions: { parserOptions: { projectService: true } },
plugins: { "simple-import-sort": simpleImportSort },
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
},
},
// Typescript
typescript.configs.recommended,
{
files: ["**/*.ts?(x)"],
rules: { "@typescript-eslint/consistent-type-imports": "error" },
},
{ files: ["**/*.ts?(x)"], ...prettierRecommended },
// Javascript
{
files: ["**/*.?(c|m)js"],
extends: [typescript.configs.disableTypeChecked],
...javascript.configs.recommended,
...prettierRecommended,
},
// JSON
{
files: ["**/*.json"],
extends: [typescript.configs.disableTypeChecked],
plugins: { json },
language: "json/json",
rules: { "json/sort-keys": "error" },
},
{ files: ["**/*.json"], ...prettierRecommended },
{ files: ["**/+(j|t)sconfig?(.*).json"], language: "json/jsonc" },
// Turbo
...turbo,
];

// .gitignore
const gitignore = await findUp(".gitignore");

if (!!gitignore) {
configs.push(includeIgnoreFile(gitignore));
}

export default defineConfig(configs);

```

### What did you expect to happen?

I'm generating a number of large JSON files (example attached) containing design tokens in [DTCG format](https://styledictionary.com/info/dtcg/) that I would like to sort the keys of for consistency with diffing. I'd like to run `eslint --fix` one after the files have been creayed and have all have all the keys sorted

[primitives.json](https://github.com/user-attachments/files/26139275/primitives.json)

### What actually happened?

I currently need to run of `eslint --fix` multiple times in order to progressively reduce the number of ordering errors until everything is eventually sorted

### Link to Minimal Reproducible Example

-

### Participation

- [ ] I am willing to submit a pull request for this issue.

### AI acknowledgment

- [x] I did not use AI to generate this issue report.
- [ ] (If the above is not checked) I have reviewed the AI-generated content before submitting.

### Additional comments

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.