11import { name , version } from "../package.json" ;
22
3- import type { CompatiblePlugin } from "@eslint-react/shared" ;
4- import reactDom from "eslint-plugin-react-dom" ;
5- import reactHooksExtra from "eslint-plugin-react-hooks-extra" ;
6- import reactNamingConvention from "eslint-plugin-react-naming-convention" ;
7- import reactWebApi from "eslint-plugin-react-web-api" ;
3+ import type { CompatibleConfig , CompatiblePlugin } from "@eslint-react/shared" ;
84import react from "eslint-plugin-react-x" ;
95
106import * as allConfig from "./configs/all" ;
@@ -24,90 +20,56 @@ import * as strictTypescriptConfig from "./configs/strict-typescript";
2420import * as webApiConfig from "./configs/web-api" ;
2521import * as xConfig from "./configs/x" ;
2622
27- import { padKeysLeft } from "./utils" ;
23+ type ConfigName =
24+ | "all"
25+ | "disable-conflict-eslint-plugin-react"
26+ | "disable-dom"
27+ | "disable-type-checked"
28+ | "disable-web-api"
29+ | "dom"
30+ | "no-deprecated"
31+ | "off"
32+ | "recommended"
33+ | "recommended-type-checked"
34+ | "recommended-typescript"
35+ | "strict"
36+ | "strict-type-checked"
37+ | "strict-typescript"
38+ | "web-api"
39+ | "x" ;
2840
29- const plugin : CompatiblePlugin = {
41+ const plugin : CompatiblePlugin & {
42+ /**
43+ * For more information about each preset, please refer to the documentation.
44+ * @see https://eslint-react.xyz/docs/presets
45+ */
46+ configs : Record < ConfigName , CompatibleConfig > ;
47+ } = {
3048 meta : {
3149 name,
3250 version,
3351 } ,
34- rules : {
35- ...react . rules ,
36- ...padKeysLeft ( reactDom . rules , "dom/" ) ,
37- ...padKeysLeft ( reactWebApi . rules , "web-api/" ) ,
38- ...padKeysLeft ( reactHooksExtra . rules , "hooks-extra/" ) ,
39- ...padKeysLeft ( reactNamingConvention . rules , "naming-convention/" ) ,
40- } ,
41- } ;
42-
43- export default {
44- ...plugin ,
4552 configs : {
46- /**
47- * Enable all applicable rules from this plugin
48- */
4953 [ "all" ] : allConfig ,
50- /**
51- * Disable rules in `eslint-plugin-react` that conflict with rules in our plugins
52- */
5354 [ "disable-conflict-eslint-plugin-react" ] : disableConflictEslintPluginReact ,
54- /**
55- * Disable rules in the `dom` preset
56- */
5755 [ "disable-dom" ] : disableDomConfig ,
58- /**
59- * Disable rules that require type information
60- */
6156 [ "disable-type-checked" ] : disableTypeCheckedConfig ,
62- /**
63- * Disable rules in the `web-api` preset
64- */
6557 [ "disable-web-api" ] : disableWebApiConfig ,
66- /**
67- * Enable rules for `"react-dom"`
68- */
6958 [ "dom" ] : domConfig ,
70- /**
71- * Enable all non-deprecated rules from the `x` and `dom` presets
72- * This preset sets the severity of these rules to `"error"`
73- */
7459 [ "no-deprecated" ] : noDeprecatedConfig ,
75- /**
76- * Disable all rules in this plugin except for debug rules
77- */
7860 [ "off" ] : offConfig ,
79- /**
80- * Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects
81- * This preset includes the `x`, `dom`, and `web-api` presets
82- */
8361 [ "recommended" ] : recommendedConfig ,
84- /**
85- * Same as the `recommended-typescript` preset but enables additional rules that require type information
86- */
8762 [ "recommended-type-checked" ] : recommendedTypeCheckedConfig ,
88- /**
89- * Same as the `recommended` preset but disables rules that can be enforced by TypeScript
90- */
9163 [ "recommended-typescript" ] : recommendedTypeScriptConfig ,
92- /**
93- * More strict version of the `recommended` preset
94- */
9564 [ "strict" ] : strictConfig ,
96- /**
97- * Same as the `strict-typescript` preset but enables additional rules that require type information
98- */
9965 [ "strict-type-checked" ] : strictTypeCheckedConfig ,
100- /**
101- * Same as the `strict` preset but disables rules that can be enforced by TypeScript
102- */
10366 [ "strict-typescript" ] : strictTypescriptConfig ,
104- /**
105- * Enable rules for interacting with Web APIs
106- */
10767 [ "web-api" ] : webApiConfig ,
108- /**
109- * Enable rules for `"react"`
110- */
11168 [ "x" ] : xConfig ,
11269 } ,
70+ rules : {
71+ ...react . rules ,
72+ } ,
11373} ;
74+
75+ export default plugin ;
0 commit comments