Skip to content

Commit 4a940ee

Browse files
authored
Add strict presets (#1266)
Signed-off-by: REL1CX <[email protected]>
1 parent e2a5660 commit 4a940ee

File tree

18 files changed

+141
-279
lines changed

18 files changed

+141
-279
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ export default defineConfig([
127127
Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects.\
128128
_This preset includes the `x`, `dom`, and `web-api` presets._
129129

130+
- `strict`\
131+
Same as the `recommended` preset but enables additional strict rules.
132+
130133
### TypeScript Specialized
131134

132135
- `recommended-typescript`\
@@ -135,6 +138,12 @@ export default defineConfig([
135138
- `recommended-type-checked`\
136139
Same as the `recommended-typescript` preset but enables additional rules that require type information.
137140

141+
- `strict-typescript`\
142+
Same as the `strict` preset but disables rules that can be enforced by TypeScript.
143+
144+
- `strict-type-checked`\
145+
Same as the `strict-typescript` preset but enables additional rules that require type information.
146+
138147
### Other
139148

140149
- `disable-dom`\

apps/website/content/docs/community.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const projects = [
2929
{ owner: "tisoap", repo: "react-flow-smart-edge" },
3030
{ owner: "toss", repo: "suspensive" },
3131
{ owner: "XYOracleNetwork", repo: "sdk-xyo-react-js" },
32+
{ owner: "yjs", repo: "yjs-inspector" },
3233
];
3334

3435
export const presets = [

apps/website/content/docs/presets.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ The following presets are available in `@eslint-react/eslint-plugin`:
1919
Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects.\
2020
_This preset includes the `x`, `dom`, and `web-api` presets._
2121

22+
- `strict` (beta)\
23+
Same as the `recommended` preset but enables additional strict rules.
24+
2225
## TypeScript Specialized
2326

2427
- `recommended-typescript`\
@@ -27,6 +30,12 @@ The following presets are available in `@eslint-react/eslint-plugin`:
2730
- `recommended-type-checked`\
2831
Same as the `recommended-typescript` preset but enables additional rules that require type information.
2932

33+
- `strict-typescript` (beta)\
34+
Same as the `strict` preset but disables rules that can be enforced by TypeScript.
35+
36+
- `strict-type-checked` (beta)\
37+
Same as the `strict-typescript` preset but enables additional rules that require type information.
38+
3039
### Combined (beta)
3140

3241
- `no-deprecated`\

examples/next/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default defineConfig([
4242
{
4343
files: TSCONFIG.include,
4444
extends: [
45-
eslintReact.configs["recommended-type-checked"],
45+
eslintReact.configs["strict-type-checked"],
4646
eslintPluginReactRefresh.configs.recommended,
4747
eslintPluginReactHooks.configs.flat["recommended-latest"] ?? [],
4848
],

examples/next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"react-dom": "^19.2.0"
1616
},
1717
"devDependencies": {
18-
"@eslint-react/eslint-plugin": "2.0.6",
18+
"@eslint-react/eslint-plugin": "workspace:*",
1919
"@eslint/compat": "^1.4.0",
2020
"@eslint/config-inspector": "^1.3.0",
2121
"@eslint/js": "^9.37.0",

examples/react-dom/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default defineConfig([
5353
{
5454
files: TSCONFIG_APP.include,
5555
extends: [
56-
eslintReact.configs["recommended-type-checked"],
56+
eslintReact.configs["strict-type-checked"],
5757
eslintPluginReactHooks.configs.flat["recommended-latest"] ?? [],
5858
eslintPluginReactRefresh.configs.recommended,
5959
],

packages/plugins/eslint-plugin/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ export default defineConfig([
127127
Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects.\
128128
_This preset includes the `x`, `dom`, and `web-api` presets._
129129

130+
- `strict`\
131+
Same as the `recommended` preset but enables additional strict rules.
132+
130133
### TypeScript Specialized
131134

132135
- `recommended-typescript`\
@@ -135,6 +138,12 @@ export default defineConfig([
135138
- `recommended-type-checked`\
136139
Same as the `recommended-typescript` preset but enables additional rules that require type information.
137140

141+
- `strict-typescript`\
142+
Same as the `strict` preset but disables rules that can be enforced by TypeScript.
143+
144+
- `strict-type-checked`\
145+
Same as the `strict-typescript` preset but enables additional rules that require type information.
146+
138147
### Other
139148

140149
- `disable-dom`\
@@ -174,8 +183,8 @@ ESLint React is not affiliated with Meta Corporation or [facebook/react](https:/
174183

175184
Contributions are welcome!
176185

177-
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/main/.github/CONTRIBUTING.md).
186+
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/add-strict-presets/.github/CONTRIBUTING.md).
178187

179188
## License
180189

181-
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Rel1cx/eslint-react/tree/main/LICENSE) file for details.
190+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Rel1cx/eslint-react/tree/add-strict-presets/LICENSE) file for details.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { RuleConfig } from "@eslint-react/kit";
2+
3+
export const rules = {
4+
"@eslint-react/no-leaked-conditional-rendering": "warn",
5+
"@eslint-react/no-unused-props": "warn",
6+
} as const satisfies Record<string, RuleConfig>;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { RuleConfig } from "@eslint-react/kit";
2+
3+
export const rules = {
4+
"@eslint-react/dom/no-string-style-prop": "off",
5+
"@eslint-react/dom/no-unknown-property": "off",
6+
"@eslint-react/jsx-no-duplicate-props": "off",
7+
"@eslint-react/jsx-uses-react": "off",
8+
"@eslint-react/jsx-uses-vars": "off",
9+
} as const satisfies Record<string, RuleConfig>;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ export const rules = {
99
"@eslint-react/dom/no-find-dom-node": "error",
1010
"@eslint-react/dom/no-flush-sync": "error",
1111
"@eslint-react/dom/no-hydrate": "error",
12-
"@eslint-react/dom/no-missing-button-type": "warn",
13-
"@eslint-react/dom/no-missing-iframe-sandbox": "warn",
12+
"@eslint-react/dom/no-missing-button-type": "off",
13+
"@eslint-react/dom/no-missing-iframe-sandbox": "off",
1414
"@eslint-react/dom/no-namespace": "error",
1515
"@eslint-react/dom/no-render": "error",
1616
"@eslint-react/dom/no-render-return-value": "error",
1717
"@eslint-react/dom/no-script-url": "warn",
1818
"@eslint-react/dom/no-unsafe-iframe-sandbox": "warn",
19-
"@eslint-react/dom/no-unsafe-target-blank": "warn",
19+
"@eslint-react/dom/no-unsafe-target-blank": "off",
2020
"@eslint-react/dom/no-use-form-state": "error",
2121
"@eslint-react/dom/no-void-elements-with-children": "error",
2222
} as const satisfies Record<string, RuleConfig>;

0 commit comments

Comments
 (0)