Skip to content

Commit 0dfdc50

Browse files
Logicer16ota-meshi
andauthored
Refine flat config types (#322)
Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>
1 parent 1691641 commit 0dfdc50

8 files changed

+20
-9
lines changed

.changeset/happy-penguins-search.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-jsonc": minor
3+
---
4+
5+
feat: improved compatibility with `@types/eslint` for flat config.

lib/configs/flat/all.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { rules } from "../../utils/rules";
22
import base from "./base";
3-
const all: Record<string, string> = {};
3+
import type { Linter } from "eslint";
4+
const all: Linter.RulesRecord = {};
45
for (const rule of rules) {
56
if (rule.meta.docs.ruleId === "jsonc/sort-array-values") continue;
67
all[rule.meta.docs.ruleId] = "error";
@@ -13,4 +14,4 @@ export default [
1314
...all,
1415
},
1516
},
16-
];
17+
] satisfies Linter.FlatConfig[];

lib/configs/flat/base.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ESLint } from "eslint";
1+
import type { ESLint, Linter } from "eslint";
22
import * as parser from "jsonc-eslint-parser";
33
export default [
44
{
@@ -28,4 +28,4 @@ export default [
2828
"no-unused-vars": "off",
2929
},
3030
},
31-
];
31+
] satisfies Linter.FlatConfig[];

lib/configs/flat/prettier.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// IMPORTANT!
22
// This file has been automatically generated,
33
// in order to update its content execute "npm run update"
4+
import type { Linter } from "eslint";
45
import base from "./base";
56
export default [
67
...base,
@@ -23,4 +24,4 @@ export default [
2324
"jsonc/space-unary-ops": "off",
2425
},
2526
},
26-
];
27+
] satisfies Linter.FlatConfig[];

lib/configs/flat/recommended-with-json.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// IMPORTANT!
22
// This file has been automatically generated,
33
// in order to update its content execute "npm run update"
4+
import type { Linter } from "eslint";
45
import base from "./base";
56
export default [
67
...base,
@@ -38,4 +39,4 @@ export default [
3839
"jsonc/vue-custom-block/no-parsing-error": "error",
3940
},
4041
},
41-
];
42+
] satisfies Linter.FlatConfig[];

lib/configs/flat/recommended-with-json5.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// IMPORTANT!
22
// This file has been automatically generated,
33
// in order to update its content execute "npm run update"
4+
import type { Linter } from "eslint";
45
import base from "./base";
56
export default [
67
...base,
@@ -27,4 +28,4 @@ export default [
2728
"jsonc/vue-custom-block/no-parsing-error": "error",
2829
},
2930
},
30-
];
31+
] satisfies Linter.FlatConfig[];

lib/configs/flat/recommended-with-jsonc.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// IMPORTANT!
22
// This file has been automatically generated,
33
// in order to update its content execute "npm run update"
4+
import type { Linter } from "eslint";
45
import base from "./base";
56
export default [
67
...base,
@@ -36,4 +37,4 @@ export default [
3637
"jsonc/vue-custom-block/no-parsing-error": "error",
3738
},
3839
},
39-
];
40+
] satisfies Linter.FlatConfig[];

tools/update-rulesets.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ for (const rec of ["json", "jsonc", "json5", "prettier"] as const) {
103103
* This file has been automatically generated,
104104
* in order to update its content execute "npm run update"
105105
*/
106+
import type { Linter } from "eslint";
106107
import base from './base';
107108
export default [
108109
...base,
@@ -117,7 +118,7 @@ export default [
117118
.join(",\n")}
118119
},
119120
}
120-
]
121+
] satisfies Linter.FlatConfig[]
121122
`;
122123

123124
const filePath = path.resolve(

0 commit comments

Comments
 (0)