diff --git a/.changeset/happy-penguins-search.md b/.changeset/happy-penguins-search.md new file mode 100644 index 00000000..6d3744d6 --- /dev/null +++ b/.changeset/happy-penguins-search.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-jsonc": minor +--- + +feat: improved compatibility with `@types/eslint` for flat config. diff --git a/lib/configs/flat/all.ts b/lib/configs/flat/all.ts index 7f358a72..d62b453d 100644 --- a/lib/configs/flat/all.ts +++ b/lib/configs/flat/all.ts @@ -1,6 +1,7 @@ import { rules } from "../../utils/rules"; import base from "./base"; -const all: Record = {}; +import type { Linter } from "eslint"; +const all: Linter.RulesRecord = {}; for (const rule of rules) { if (rule.meta.docs.ruleId === "jsonc/sort-array-values") continue; all[rule.meta.docs.ruleId] = "error"; @@ -13,4 +14,4 @@ export default [ ...all, }, }, -]; +] satisfies Linter.FlatConfig[]; diff --git a/lib/configs/flat/base.ts b/lib/configs/flat/base.ts index 7fee4ee9..e77399fc 100644 --- a/lib/configs/flat/base.ts +++ b/lib/configs/flat/base.ts @@ -1,4 +1,4 @@ -import type { ESLint } from "eslint"; +import type { ESLint, Linter } from "eslint"; import * as parser from "jsonc-eslint-parser"; export default [ { @@ -28,4 +28,4 @@ export default [ "no-unused-vars": "off", }, }, -]; +] satisfies Linter.FlatConfig[]; diff --git a/lib/configs/flat/prettier.ts b/lib/configs/flat/prettier.ts index 1a05470f..9cc953c8 100644 --- a/lib/configs/flat/prettier.ts +++ b/lib/configs/flat/prettier.ts @@ -1,6 +1,7 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "npm run update" +import type { Linter } from "eslint"; import base from "./base"; export default [ ...base, @@ -23,4 +24,4 @@ export default [ "jsonc/space-unary-ops": "off", }, }, -]; +] satisfies Linter.FlatConfig[]; diff --git a/lib/configs/flat/recommended-with-json.ts b/lib/configs/flat/recommended-with-json.ts index 8f64b30e..6d09647a 100644 --- a/lib/configs/flat/recommended-with-json.ts +++ b/lib/configs/flat/recommended-with-json.ts @@ -1,6 +1,7 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "npm run update" +import type { Linter } from "eslint"; import base from "./base"; export default [ ...base, @@ -38,4 +39,4 @@ export default [ "jsonc/vue-custom-block/no-parsing-error": "error", }, }, -]; +] satisfies Linter.FlatConfig[]; diff --git a/lib/configs/flat/recommended-with-json5.ts b/lib/configs/flat/recommended-with-json5.ts index 5bae83f0..87cf7b2e 100644 --- a/lib/configs/flat/recommended-with-json5.ts +++ b/lib/configs/flat/recommended-with-json5.ts @@ -1,6 +1,7 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "npm run update" +import type { Linter } from "eslint"; import base from "./base"; export default [ ...base, @@ -27,4 +28,4 @@ export default [ "jsonc/vue-custom-block/no-parsing-error": "error", }, }, -]; +] satisfies Linter.FlatConfig[]; diff --git a/lib/configs/flat/recommended-with-jsonc.ts b/lib/configs/flat/recommended-with-jsonc.ts index 29887ca4..a53dd1c1 100644 --- a/lib/configs/flat/recommended-with-jsonc.ts +++ b/lib/configs/flat/recommended-with-jsonc.ts @@ -1,6 +1,7 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "npm run update" +import type { Linter } from "eslint"; import base from "./base"; export default [ ...base, @@ -36,4 +37,4 @@ export default [ "jsonc/vue-custom-block/no-parsing-error": "error", }, }, -]; +] satisfies Linter.FlatConfig[]; diff --git a/tools/update-rulesets.ts b/tools/update-rulesets.ts index f2757464..a393ea38 100644 --- a/tools/update-rulesets.ts +++ b/tools/update-rulesets.ts @@ -103,6 +103,7 @@ for (const rec of ["json", "jsonc", "json5", "prettier"] as const) { * This file has been automatically generated, * in order to update its content execute "npm run update" */ +import type { Linter } from "eslint"; import base from './base'; export default [ ...base, @@ -117,7 +118,7 @@ export default [ .join(",\n")} }, } -] +] satisfies Linter.FlatConfig[] `; const filePath = path.resolve(