Skip to content

Commit f3083c7

Browse files
committed
fix: add ESLint compatibility types and update plugins exports, closes #1200
- Add CompatibleConfig and CompatiblePlugin interface definitions - Update all plugin packages to use new compatibility types - Add documentation for new compatibility interfaces - Update package.json files across examples and packages - Add compatibility-types.ts to shared package
1 parent 55a64c6 commit f3083c7

File tree

29 files changed

+166
-68
lines changed

29 files changed

+166
-68
lines changed

examples/next/eslint.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import eslintPluginNext from "@next/eslint-plugin-next";
44
import gitignore from "eslint-config-flat-gitignore";
55
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
66
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
7+
import { defineConfig } from "eslint/config";
78
import tseslint from "typescript-eslint";
89

910
import TSCONFIG from "./tsconfig.json" with { type: "json" };
@@ -13,7 +14,7 @@ const GLOB_JS = ["**/*.js", "**/*.jsx"];
1314
const GLOB_APP = ["app/**/*.{js,ts,jsx,tsx}"];
1415
const GLOB_CONFIG = ["**/*.config.{js,mjs,ts,tsx}"];
1516

16-
export default tseslint.config(
17+
export default defineConfig([
1718
gitignore(),
1819
{
1920
files: GLOB_TS,
@@ -65,4 +66,4 @@ export default tseslint.config(
6566
"no-console": "off",
6667
},
6768
},
68-
);
69+
]);

examples/next/eslint.config.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import eslintJs from "@eslint/js";
33
import eslintPluginNext from "@next/eslint-plugin-next";
44
import gitignore from "eslint-config-flat-gitignore";
55
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
6-
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
6+
import { defineConfig } from "eslint/config";
77
import tseslint from "typescript-eslint";
88

99
import TSCONFIG from "./tsconfig.json" with { type: "json" };
@@ -13,7 +13,7 @@ const GLOB_JS = ["**/*.js", "**/*.jsx"];
1313
const GLOB_APP = ["app/**/*.{js,ts,jsx,tsx}"];
1414
const GLOB_CONFIG = ["**/*.config.{js,mjs,ts,tsx}"];
1515

16-
export default tseslint.config(
16+
export default defineConfig([
1717
gitignore(),
1818
{
1919
files: GLOB_TS,
@@ -65,4 +65,4 @@ export default tseslint.config(
6565
"no-console": "off",
6666
},
6767
},
68-
);
68+
]);

examples/react-dom/eslint.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import eslintReact from "@eslint-react/eslint-plugin";
22
import eslintJs from "@eslint/js";
33
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
44
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
5+
import { defineConfig } from "eslint/config";
56
import tseslint from "typescript-eslint";
67

78
import TSCONFIG_APP from "./tsconfig.app.json" with { type: "json" };
89
import TSCONFIG_NODE from "./tsconfig.node.json" with { type: "json" };
910

1011
const GLOB_TS = ["**/*.ts", "**/*.tsx"];
1112

12-
export default tseslint.config(
13+
export default defineConfig([
1314
{
1415
files: GLOB_TS,
1516
extends: [
@@ -60,4 +61,4 @@ export default tseslint.config(
6061
...eslintPluginReactHooks.configs.recommended.rules,
6162
},
6263
},
63-
);
64+
]);

examples/with-ts-blank-eslint-parser/eslint.config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
// @ts-check
21
import eslintReact from "@eslint-react/eslint-plugin";
32
import eslintJs from "@eslint/js";
43
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
54
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
5+
import { defineConfig } from "eslint/config";
66
import globals from "globals";
77
import tsBlankEslintParser from "ts-blank-eslint-parser";
8-
import tseslint from "typescript-eslint";
98

109
import TSCONFIG_APP from "./tsconfig.app.json" with { type: "json" };
1110
import TSCONFIG_NODE from "./tsconfig.node.json" with { type: "json" };
1211

13-
export default tseslint.config(
12+
export default defineConfig([
1413
// base configuration for browser environment source files
1514
{
1615
files: TSCONFIG_APP.include,
@@ -54,4 +53,4 @@ export default tseslint.config(
5453
...eslintPluginReactHooks.configs.recommended.rules,
5554
},
5655
},
57-
);
56+
]);

packages/plugins/eslint-plugin-react-debug/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"./package.json"
4444
],
4545
"scripts": {
46-
"build": "tsup --dts-resolve",
46+
"build": "tsup",
4747
"lint:publish": "publint",
4848
"lint:ts": "tsc --noEmit",
4949
"publish": "pnpm run build && pnpm run lint:publish"
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import type { RulePreset } from "@eslint-react/kit";
2+
import type { CompatibleConfig } from "@eslint-react/shared";
23

34
import * as allConfig from "./configs/all";
45
import { plugin } from "./plugin";
56

6-
function makeConfig(config: { name: string; rules: RulePreset }) {
7+
function toFlatConfig(config: CompatibleConfig) {
78
return {
89
...config,
910
plugins: {
@@ -12,7 +13,7 @@ function makeConfig(config: { name: string; rules: RulePreset }) {
1213
};
1314
}
1415

15-
function makeLegacyConfig({ rules }: { rules: RulePreset }) {
16+
function toLegacyConfig({ rules }: { rules: RulePreset }) {
1617
return {
1718
plugins: ["react-debug"],
1819
rules,
@@ -22,7 +23,7 @@ function makeLegacyConfig({ rules }: { rules: RulePreset }) {
2223
export default {
2324
...plugin,
2425
configs: {
25-
["all"]: makeConfig(allConfig),
26-
["all-legacy"]: makeLegacyConfig(allConfig),
26+
["all"]: toFlatConfig(allConfig),
27+
["all-legacy"]: toLegacyConfig(allConfig),
2728
},
2829
};

packages/plugins/eslint-plugin-react-debug/src/plugin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
import type { CompatiblePlugin } from "@eslint-react/shared";
2+
13
import { name, version } from "../package.json";
4+
25
import classComponent from "./rules/class-component";
36
import functionComponent from "./rules/function-component";
47
import hook from "./rules/hook";
58
import isFromReact from "./rules/is-from-react";
69
import jsx from "./rules/jsx";
710

8-
export const plugin = {
11+
export const plugin: CompatiblePlugin = {
912
meta: {
1013
name,
1114
version,
@@ -21,4 +24,4 @@ export const plugin = {
2124
/** @deprecated Use `hook` instead */
2225
"react-hooks": hook,
2326
},
24-
} as const;
27+
};

packages/plugins/eslint-plugin-react-dom/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"./package.json"
4444
],
4545
"scripts": {
46-
"build": "tsup --dts-resolve",
46+
"build": "tsup",
4747
"lint:publish": "publint",
4848
"lint:ts": "tsc --noEmit",
4949
"publish": "pnpm run build && pnpm run lint:publish"
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import type { RulePreset } from "@eslint-react/kit";
2+
import type { CompatibleConfig } from "@eslint-react/shared";
23

34
import * as recommendedConfig from "./configs/recommended";
45
import { plugin } from "./plugin";
56

6-
function makeConfig(config: { name: string; rules: RulePreset }) {
7+
function toFlatConfig(config: CompatibleConfig) {
78
return {
89
...config,
910
plugins: {
@@ -12,7 +13,7 @@ function makeConfig(config: { name: string; rules: RulePreset }) {
1213
};
1314
}
1415

15-
function makeLegacyConfig({ rules }: { rules: RulePreset }) {
16+
function toLegacyConfig({ rules }: { rules: RulePreset }) {
1617
return {
1718
plugins: ["react-dom"],
1819
rules,
@@ -22,7 +23,7 @@ function makeLegacyConfig({ rules }: { rules: RulePreset }) {
2223
export default {
2324
...plugin,
2425
configs: {
25-
["recommended"]: makeConfig(recommendedConfig),
26-
["recommended-legacy"]: makeLegacyConfig(recommendedConfig),
26+
["recommended"]: toFlatConfig(recommendedConfig),
27+
["recommended-legacy"]: toLegacyConfig(recommendedConfig),
2728
},
2829
};

packages/plugins/eslint-plugin-react-dom/src/plugin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import type { CompatiblePlugin } from "@eslint-react/shared";
2+
13
import { name, version } from "../package.json";
4+
25
import noDangerouslySetInnerHTML from "./rules/no-dangerously-set-innerhtml";
36
import noDangerouslySetInnerHTMLWithChildren from "./rules/no-dangerously-set-innerhtml-with-children";
47
import noFindDomNode from "./rules/no-find-dom-node";
@@ -16,7 +19,7 @@ import noUnsafeTargetBlank from "./rules/no-unsafe-target-blank";
1619
import noUseFormState from "./rules/no-use-form-state";
1720
import noVoidElementsWithChildren from "./rules/no-void-elements-with-children";
1821

19-
export const plugin = {
22+
export const plugin: CompatiblePlugin = {
2023
meta: {
2124
name,
2225
version,
@@ -43,4 +46,4 @@ export const plugin = {
4346
/** @deprecated Use `no-void-elements-with-children` instead */
4447
"no-children-in-void-dom-elements": noVoidElementsWithChildren,
4548
},
46-
} as const;
49+
};

0 commit comments

Comments
 (0)