Skip to content

Commit

Permalink
Refine flat config types (#322)
Browse files Browse the repository at this point in the history
Co-authored-by: Yosuke Ota <[email protected]>
  • Loading branch information
Logicer16 and ota-meshi authored Apr 1, 2024
1 parent 1691641 commit 0dfdc50
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-penguins-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-jsonc": minor
---

feat: improved compatibility with `@types/eslint` for flat config.
5 changes: 3 additions & 2 deletions lib/configs/flat/all.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { rules } from "../../utils/rules";
import base from "./base";
const all: Record<string, string> = {};
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";
Expand All @@ -13,4 +14,4 @@ export default [
...all,
},
},
];
] satisfies Linter.FlatConfig[];
4 changes: 2 additions & 2 deletions lib/configs/flat/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ESLint } from "eslint";
import type { ESLint, Linter } from "eslint";
import * as parser from "jsonc-eslint-parser";
export default [
{
Expand Down Expand Up @@ -28,4 +28,4 @@ export default [
"no-unused-vars": "off",
},
},
];
] satisfies Linter.FlatConfig[];
3 changes: 2 additions & 1 deletion lib/configs/flat/prettier.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -23,4 +24,4 @@ export default [
"jsonc/space-unary-ops": "off",
},
},
];
] satisfies Linter.FlatConfig[];
3 changes: 2 additions & 1 deletion lib/configs/flat/recommended-with-json.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -38,4 +39,4 @@ export default [
"jsonc/vue-custom-block/no-parsing-error": "error",
},
},
];
] satisfies Linter.FlatConfig[];
3 changes: 2 additions & 1 deletion lib/configs/flat/recommended-with-json5.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -27,4 +28,4 @@ export default [
"jsonc/vue-custom-block/no-parsing-error": "error",
},
},
];
] satisfies Linter.FlatConfig[];
3 changes: 2 additions & 1 deletion lib/configs/flat/recommended-with-jsonc.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -36,4 +37,4 @@ export default [
"jsonc/vue-custom-block/no-parsing-error": "error",
},
},
];
] satisfies Linter.FlatConfig[];
3 changes: 2 additions & 1 deletion tools/update-rulesets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -117,7 +118,7 @@ export default [
.join(",\n")}
},
}
]
] satisfies Linter.FlatConfig[]
`;

const filePath = path.resolve(
Expand Down

0 comments on commit 0dfdc50

Please sign in to comment.