Skip to content

Commit 5ec43a9

Browse files
authored
Make ESLint plugin backwards compatible with v8 (#7280)
1 parent 33fed14 commit 5ec43a9

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

packages/eslint-config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const eslintPluginRules = require("./eslint-plugin-rules.js");
2626
const tsEslintRules = require("./typescript-eslint-rules.js");
2727

2828
module.exports = tseslint.config(
29-
blueprintPlugin.configs.recommended,
29+
blueprintPlugin.flatConfigs.recommended,
3030
importPlugin.flatConfigs.typescript,
3131
{
3232
plugins: {

packages/eslint-plugin/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
"test": "SWC_NODE_PROJECT=./tsconfig.test.json mocha --require @swc-node/register,test/setup.ts --watch-extensions ts,tsx 'test/**/*.{ts,tsx}'"
1212
},
1313
"dependencies": {
14-
"@typescript-eslint/utils": "^8.23.0",
15-
"eslint": "^9.20.0"
14+
"@typescript-eslint/utils": "^8.23.0"
15+
},
16+
"peerDependencies": {
17+
"eslint": "^8.57 || ^9.0.0"
1618
},
1719
"devDependencies": {
1820
"@blueprintjs/node-build-scripts": "workspace:^",

packages/eslint-plugin/src/index.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,31 @@ import type { TSESLint } from "@typescript-eslint/utils";
1717

1818
import rules from "./rules";
1919

20-
const blueprintPlugin = { configs: { recommended: {} }, rules };
20+
type ConfigName = "recommended";
2121

22-
// Assign the config here so that we can reference blueprintPlugin.
23-
const configs: { [c in keyof (typeof blueprintPlugin)["configs"]]: TSESLint.FlatConfig.Config } = {
24-
/**
25-
* Enables all Blueprint-specific lint rules defined in this package.
26-
*/
27-
recommended: {
28-
plugins: { "@blueprintjs": blueprintPlugin },
29-
rules: {
30-
"@blueprintjs/classes-constants": "error",
31-
"@blueprintjs/html-components": "error",
32-
"@blueprintjs/no-deprecated-components": "error",
33-
"@blueprintjs/no-deprecated-type-references": "error",
34-
},
22+
const blueprintPlugin = {
23+
configs: { recommended: {} } as Record<ConfigName, TSESLint.ClassicConfig.Config>,
24+
flatConfigs: { recommended: {} } as Record<ConfigName, TSESLint.FlatConfig.Config>,
25+
rules,
26+
};
27+
28+
// The recommended config enables all Blueprint-specific lint rules defined in this package.
29+
const config: TSESLint.ClassicConfig.Config = {
30+
plugins: ["@blueprintjs"],
31+
rules: {
32+
"@blueprintjs/classes-constants": "error",
33+
"@blueprintjs/html-components": "error",
34+
"@blueprintjs/no-deprecated-components": "error",
35+
"@blueprintjs/no-deprecated-type-references": "error",
3536
},
3637
};
37-
Object.assign(blueprintPlugin.configs, configs);
38+
const flatConfig: TSESLint.FlatConfig.Config = {
39+
...config,
40+
plugins: { "@blueprintjs": blueprintPlugin },
41+
};
42+
43+
// Assign the config here so that we can reference blueprintPlugin.
44+
Object.assign(blueprintPlugin.configs.recommended, config);
45+
Object.assign(blueprintPlugin.flatConfigs.recommended, flatConfig);
3846

3947
export = blueprintPlugin;

yarn.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,10 @@ __metadata:
701701
"@typescript-eslint/rule-tester": "npm:^8.23.0"
702702
"@typescript-eslint/utils": "npm:^8.23.0"
703703
dedent: "npm:^1.5.1"
704-
eslint: "npm:^9.20.0"
705704
mocha: "npm:^10.2.0"
706705
typescript: "npm:~5.3.3"
706+
peerDependencies:
707+
eslint: ^8.57 || ^9.0.0
707708
languageName: unknown
708709
linkType: soft
709710

0 commit comments

Comments
 (0)