Skip to content

Bug: sort-keys autofix requires multiple passes #222

@benedfit

Description

@benedfit

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] }]);
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 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

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

  • 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

Metadata

Metadata

Assignees

Labels

acceptedbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status

Ready to Implement

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions