Skip to content

Commit b784c9a

Browse files
authored
Add no-deprecated preset (#1264)
1 parent ca3ca4c commit b784c9a

File tree

9 files changed

+189
-117
lines changed

9 files changed

+189
-117
lines changed

apps/website/content/docs/migration.mdx

Lines changed: 105 additions & 105 deletions
Large diffs are not rendered by default.

apps/website/content/docs/presets.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ The following presets are available in `@eslint-react/eslint-plugin`:
2727
- `recommended-type-checked`\
2828
Same as the `recommended-typescript` preset but enables additional rules that require type information.
2929

30+
### Combined
31+
32+
- `no-deprecated`\
33+
Enable all non-deprecated rules from the `x`, `dom`, and `web-api` presets.\
34+
_This preset sets the severity of these rules to `"error"`._
35+
3036
## Other
3137

3238
- `disable-dom`\

packages/plugins/eslint-plugin/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ ESLint React is not affiliated with Meta Corporation or [facebook/react](https:/
174174

175175
Contributions are welcome!
176176

177-
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/main/.github/CONTRIBUTING.md).
177+
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/add-no-deprecated-preset/.github/CONTRIBUTING.md).
178178

179179
## License
180180

181-
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Rel1cx/eslint-react/tree/main/LICENSE) file for details.
181+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Rel1cx/eslint-react/tree/add-no-deprecated-preset/LICENSE) file for details.

packages/plugins/eslint-plugin/src/configs/all.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ export const plugins = {
116116
};
117117

118118
export const settings = {
119-
...dom.settings,
119+
...x.settings,
120120
};

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { RuleConfig } from "@eslint-react/kit";
2-
import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared";
32
import reactDom from "eslint-plugin-react-dom";
43

54
export const name = "@eslint-react/dom";
@@ -25,7 +24,3 @@ export const rules = {
2524
export const plugins = {
2625
"@eslint-react/dom": reactDom,
2726
};
28-
29-
export const settings = {
30-
"react-x": DEFAULT_ESLINT_REACT_SETTINGS,
31-
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { RuleConfig } from "@eslint-react/kit";
2+
3+
import * as dom from "./dom";
4+
import * as x from "./x";
5+
6+
export const name = "@eslint-react/no-deprecated";
7+
8+
export const rules = {
9+
"@eslint-react/no-component-will-mount": "error",
10+
"@eslint-react/no-component-will-receive-props": "error",
11+
"@eslint-react/no-component-will-update": "error",
12+
"@eslint-react/no-create-ref": "error",
13+
"@eslint-react/no-forward-ref": "error",
14+
15+
"@eslint-react/dom/no-find-dom-node": "error",
16+
"@eslint-react/dom/no-hydrate": "error",
17+
"@eslint-react/dom/no-render": "error",
18+
"@eslint-react/dom/no-render-return-value": "error",
19+
} as const satisfies Record<string, RuleConfig>;
20+
21+
export const plugins = {
22+
...x.plugins,
23+
...dom.plugins,
24+
};

packages/plugins/eslint-plugin/src/configs/recommended.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ export const plugins = {
2828
};
2929

3030
export const settings = {
31-
...dom.settings,
31+
...x.settings,
3232
};

packages/plugins/eslint-plugin/src/configs/web-api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { RuleConfig } from "@eslint-react/kit";
22
import reactWebApi from "eslint-plugin-react-web-api";
33

4-
import * as dom from "./dom";
4+
import * as x from "./x";
55

66
export const name = "@eslint-react/web-api";
77

@@ -17,5 +17,5 @@ export const plugins = {
1717
};
1818

1919
export const settings = {
20-
...dom.settings,
20+
...x.settings,
2121
};

packages/plugins/eslint-plugin/src/index.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { name, version } from "../package.json";
2+
13
import type { CompatiblePlugin } from "@eslint-react/kit";
24
import reactDebug from "eslint-plugin-react-debug";
35
import reactDom from "eslint-plugin-react-dom";
@@ -6,7 +8,6 @@ import reactNamingConvention from "eslint-plugin-react-naming-convention";
68
import reactWebApi from "eslint-plugin-react-web-api";
79
import react from "eslint-plugin-react-x";
810

9-
import { name, version } from "../package.json";
1011
import * as allConfig from "./configs/all";
1112
import * as debugConfig from "./configs/debug";
1213
import * as disableConflictEslintPluginReact from "./configs/disable-conflict-eslint-plugin-react";
@@ -15,6 +16,7 @@ import * as disableDomConfig from "./configs/disable-dom";
1516
import * as disableTypeCheckedConfig from "./configs/disable-type-checked";
1617
import * as disableWebApiConfig from "./configs/disable-web-api";
1718
import * as domConfig from "./configs/dom";
19+
import * as noDeprecatedConfig from "./configs/no-deprecated";
1820
import * as offConfig from "./configs/off";
1921
import * as recommendedConfig from "./configs/recommended";
2022
import * as recommendedTypeCheckedConfig from "./configs/recommended-type-checked";
@@ -40,18 +42,63 @@ const plugin: CompatiblePlugin = {
4042
export default {
4143
...plugin,
4244
configs: {
45+
/**
46+
* Enable all rules in this plugin
47+
*/
4348
["all"]: allConfig,
49+
/**
50+
* Enable debug rules
51+
*/
4452
["debug"]: debugConfig,
53+
/**
54+
* Disable rules in `eslint-plugin-react` that conflict with rules in our plugins
55+
*/
4556
["disable-conflict-eslint-plugin-react"]: disableConflictEslintPluginReact,
57+
/**
58+
* Disable debug rules
59+
*/
4660
["disable-debug"]: disableDebugConfig,
61+
/**
62+
* Disable rules in the `dom` preset
63+
*/
4764
["disable-dom"]: disableDomConfig,
65+
/**
66+
* Disable rules that require type information
67+
*/
4868
["disable-type-checked"]: disableTypeCheckedConfig,
69+
/**
70+
* Disable rules in the `web-api` preset
71+
*/
4972
["disable-web-api"]: disableWebApiConfig,
73+
/**
74+
* Enable rules for `"react-dom"`
75+
*/
5076
["dom"]: domConfig,
77+
/**
78+
* Enable all non-deprecated rules from the `x`, `dom`, and `web-api` presets
79+
* This preset sets the severity of these rules to `"error"`
80+
*/
81+
["no-deprecated"]: noDeprecatedConfig,
82+
/**
83+
* Disable all rules in this plugin except for debug rules
84+
*/
5185
["off"]: offConfig,
86+
/**
87+
* Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects
88+
* This preset includes the `x`, `dom`, and `web-api` presets
89+
*/
5290
["recommended"]: recommendedConfig,
91+
/**
92+
* Same as the `recommended-typescript` preset but enables additional rules that require type information
93+
*/
5394
["recommended-type-checked"]: recommendedTypeCheckedConfig,
95+
/**
96+
* Same as the `recommended` preset but disables rules that can be enforced by TypeScript
97+
*/
5498
["recommended-typescript"]: recommendedTypeScriptConfig,
99+
/**
100+
* Enable rules for `"react"`
101+
*/
55102
["x"]: xConfig,
56103
},
57104
};

0 commit comments

Comments
 (0)