Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine flat config types #322

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading