Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export default defineConfig([
Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects.\
_This preset includes the `x`, `dom`, and `web-api` presets._

- `strict`\
Same as the `recommended` preset but enables additional strict rules.

### TypeScript Specialized

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

- `strict-typescript`\
Same as the `strict` preset but disables rules that can be enforced by TypeScript.

- `strict-type-checked`\
Same as the `strict-typescript` preset but enables additional rules that require type information.

### Other

- `disable-dom`\
Expand Down
1 change: 1 addition & 0 deletions apps/website/content/docs/community.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const projects = [
{ owner: "tisoap", repo: "react-flow-smart-edge" },
{ owner: "toss", repo: "suspensive" },
{ owner: "XYOracleNetwork", repo: "sdk-xyo-react-js" },
{ owner: "yjs", repo: "yjs-inspector" },
];

export const presets = [
Expand Down
9 changes: 9 additions & 0 deletions apps/website/content/docs/presets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ The following presets are available in `@eslint-react/eslint-plugin`:
Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects.\
_This preset includes the `x`, `dom`, and `web-api` presets._

- `strict` (beta)\
Same as the `recommended` preset but enables additional strict rules.

## TypeScript Specialized

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

- `strict-typescript` (beta)\
Same as the `strict` preset but disables rules that can be enforced by TypeScript.

- `strict-type-checked` (beta)\
Same as the `strict-typescript` preset but enables additional rules that require type information.

### Combined (beta)

- `no-deprecated`\
Expand Down
2 changes: 1 addition & 1 deletion examples/next/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default defineConfig([
{
files: TSCONFIG.include,
extends: [
eslintReact.configs["recommended-type-checked"],
eslintReact.configs["strict-type-checked"],
eslintPluginReactRefresh.configs.recommended,
eslintPluginReactHooks.configs.flat["recommended-latest"] ?? [],
],
Expand Down
2 changes: 1 addition & 1 deletion examples/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"react-dom": "^19.2.0"
},
"devDependencies": {
"@eslint-react/eslint-plugin": "2.0.6",
"@eslint-react/eslint-plugin": "workspace:*",
"@eslint/compat": "^1.4.0",
"@eslint/config-inspector": "^1.3.0",
"@eslint/js": "^9.37.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-dom/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default defineConfig([
{
files: TSCONFIG_APP.include,
extends: [
eslintReact.configs["recommended-type-checked"],
eslintReact.configs["strict-type-checked"],
eslintPluginReactHooks.configs.flat["recommended-latest"] ?? [],
eslintPluginReactRefresh.configs.recommended,
],
Expand Down
13 changes: 11 additions & 2 deletions packages/plugins/eslint-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export default defineConfig([
Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects.\
_This preset includes the `x`, `dom`, and `web-api` presets._

- `strict`\
Same as the `recommended` preset but enables additional strict rules.

### TypeScript Specialized

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

- `strict-typescript`\
Same as the `strict` preset but disables rules that can be enforced by TypeScript.

- `strict-type-checked`\
Same as the `strict-typescript` preset but enables additional rules that require type information.

### Other

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

Contributions are welcome!

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

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/Rel1cx/eslint-react/tree/main/LICENSE) file for details.
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.
6 changes: 6 additions & 0 deletions packages/plugins/eslint-plugin/src/configs/_tc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { RuleConfig } from "@eslint-react/kit";

export const rules = {
"@eslint-react/no-leaked-conditional-rendering": "warn",
"@eslint-react/no-unused-props": "warn",
} as const satisfies Record<string, RuleConfig>;
9 changes: 9 additions & 0 deletions packages/plugins/eslint-plugin/src/configs/_ts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { RuleConfig } from "@eslint-react/kit";

export const rules = {
"@eslint-react/dom/no-string-style-prop": "off",
"@eslint-react/dom/no-unknown-property": "off",
"@eslint-react/jsx-no-duplicate-props": "off",
"@eslint-react/jsx-uses-react": "off",
"@eslint-react/jsx-uses-vars": "off",
} as const satisfies Record<string, RuleConfig>;
6 changes: 3 additions & 3 deletions packages/plugins/eslint-plugin/src/configs/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export const rules = {
"@eslint-react/dom/no-find-dom-node": "error",
"@eslint-react/dom/no-flush-sync": "error",
"@eslint-react/dom/no-hydrate": "error",
"@eslint-react/dom/no-missing-button-type": "warn",
"@eslint-react/dom/no-missing-iframe-sandbox": "warn",
"@eslint-react/dom/no-missing-button-type": "off",
"@eslint-react/dom/no-missing-iframe-sandbox": "off",
"@eslint-react/dom/no-namespace": "error",
"@eslint-react/dom/no-render": "error",
"@eslint-react/dom/no-render-return-value": "error",
"@eslint-react/dom/no-script-url": "warn",
"@eslint-react/dom/no-unsafe-iframe-sandbox": "warn",
"@eslint-react/dom/no-unsafe-target-blank": "warn",
"@eslint-react/dom/no-unsafe-target-blank": "off",
"@eslint-react/dom/no-use-form-state": "error",
"@eslint-react/dom/no-void-elements-with-children": "error",
} as const satisfies Record<string, RuleConfig>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { RuleConfig } from "@eslint-react/kit";

import * as tc from "./_tc";
import * as recommendedTypeScript from "./recommended-typescript";

export const name = "@eslint-react/recommended-type-checked";

export const rules = {
...recommendedTypeScript.rules,
"@eslint-react/no-leaked-conditional-rendering": "warn",
"@eslint-react/no-unused-props": "warn",
...tc.rules,
} as const satisfies Record<string, RuleConfig>;

export const plugins = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import type { RuleConfig } from "@eslint-react/kit";

import * as ts from "./_ts";
import * as recommended from "./recommended";

export const name = "@eslint-react/recommended-typescript";

export const rules = {
...recommended.rules,
"@eslint-react/dom/no-string-style-prop": "off",
"@eslint-react/dom/no-unknown-property": "off",
"@eslint-react/jsx-no-duplicate-props": "off",
"@eslint-react/jsx-uses-react": "off",
"@eslint-react/jsx-uses-vars": "off",
...ts.rules,
} as const satisfies Record<string, RuleConfig>;

export const plugins = {
Expand Down
19 changes: 19 additions & 0 deletions packages/plugins/eslint-plugin/src/configs/strict-type-checked.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { RuleConfig } from "@eslint-react/kit";

import * as tc from "./_tc";
import * as strictTypeScript from "./strict-typescript";

export const name = "@eslint-react/strict-type-checked";

export const rules = {
...strictTypeScript.rules,
...tc.rules,
} as const satisfies Record<string, RuleConfig>;

export const plugins = {
...strictTypeScript.plugins,
};

export const settings = {
...strictTypeScript.settings,
};
19 changes: 19 additions & 0 deletions packages/plugins/eslint-plugin/src/configs/strict-typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { RuleConfig } from "@eslint-react/kit";

import * as ts from "./recommended-typescript";
import * as strict from "./strict";

export const name = "@eslint-react/strict-typescript";

export const rules = {
...strict.rules,
...ts.rules,
} as const satisfies Record<string, RuleConfig>;

export const plugins = {
...strict.plugins,
};

export const settings = {
...strict.settings,
};
35 changes: 35 additions & 0 deletions packages/plugins/eslint-plugin/src/configs/strict.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { RuleConfig } from "@eslint-react/kit";

import * as recommended from "./recommended";

export const name = "@eslint-react/strict";

export const rules = {
...recommended.rules,
"@eslint-react/jsx-no-iife": "error",
"@eslint-react/jsx-no-undef": "error",
"@eslint-react/no-children-prop": "warn",
"@eslint-react/no-class-component": "error",
"@eslint-react/no-misused-capture-owner-stack": "error",
"@eslint-react/no-unnecessary-key": "warn",
"@eslint-react/no-unnecessary-use-callback": "warn",
"@eslint-react/no-unnecessary-use-memo": "warn",
"@eslint-react/no-unstable-context-value": "warn",
"@eslint-react/no-unstable-default-props": "warn",
"@eslint-react/no-unused-props": "warn",
"@eslint-react/no-unused-state": "warn",
"@eslint-react/no-useless-fragment": "warn",
"@eslint-react/prefer-destructuring-assignment": "warn",

"@eslint-react/dom/no-missing-button-type": "warn",
"@eslint-react/dom/no-missing-iframe-sandbox": "warn",
"@eslint-react/dom/no-unsafe-target-blank": "warn",
} as const satisfies Record<string, RuleConfig>;

export const plugins = {
...recommended.plugins,
};

export const settings = {
...recommended.settings,
};
22 changes: 0 additions & 22 deletions packages/plugins/eslint-plugin/src/configs/x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ export const name = "@eslint-react/x";
export const rules = {
"@eslint-react/jsx-no-comment-textnodes": "warn",
"@eslint-react/jsx-no-duplicate-props": "warn",
"@eslint-react/jsx-no-iife": "off",
"@eslint-react/jsx-no-undef": "off",
"@eslint-react/jsx-shorthand-boolean": "off",
"@eslint-react/jsx-shorthand-fragment": "off",
"@eslint-react/jsx-uses-react": "warn",
"@eslint-react/jsx-uses-vars": "warn",
"@eslint-react/no-access-state-in-setstate": "error",
Expand All @@ -19,9 +15,7 @@ export const rules = {
"@eslint-react/no-children-for-each": "warn",
"@eslint-react/no-children-map": "warn",
"@eslint-react/no-children-only": "warn",
"@eslint-react/no-children-prop": "off",
"@eslint-react/no-children-to-array": "warn",
"@eslint-react/no-class-component": "off",
"@eslint-react/no-clone-element": "warn",
"@eslint-react/no-component-will-mount": "error",
"@eslint-react/no-component-will-receive-props": "error",
Expand All @@ -31,14 +25,9 @@ export const rules = {
"@eslint-react/no-default-props": "error",
"@eslint-react/no-direct-mutation-state": "error",
"@eslint-react/no-duplicate-key": "error",
"@eslint-react/no-forbidden-props": "off",
"@eslint-react/no-forward-ref": "warn",
"@eslint-react/no-implicit-key": "warn",
"@eslint-react/no-leaked-conditional-rendering": "off",
"@eslint-react/no-missing-component-display-name": "off",
"@eslint-react/no-missing-context-display-name": "off",
"@eslint-react/no-missing-key": "error",
"@eslint-react/no-misused-capture-owner-stack": "off",
"@eslint-react/no-nested-component-definitions": "error",
"@eslint-react/no-nested-lazy-component-declarations": "error",
"@eslint-react/no-prop-types": "error",
Expand All @@ -47,24 +36,13 @@ export const rules = {
"@eslint-react/no-set-state-in-component-did-update": "warn",
"@eslint-react/no-set-state-in-component-will-update": "warn",
"@eslint-react/no-string-refs": "error",
"@eslint-react/no-unnecessary-key": "off",
"@eslint-react/no-unnecessary-use-callback": "off",
"@eslint-react/no-unnecessary-use-memo": "off",
"@eslint-react/no-unnecessary-use-prefix": "warn",
"@eslint-react/no-unsafe-component-will-mount": "warn",
"@eslint-react/no-unsafe-component-will-receive-props": "warn",
"@eslint-react/no-unsafe-component-will-update": "warn",
"@eslint-react/no-unstable-context-value": "warn",
"@eslint-react/no-unstable-default-props": "warn",
"@eslint-react/no-unused-class-component-members": "warn",
"@eslint-react/no-unused-props": "off",
"@eslint-react/no-unused-state": "warn",
"@eslint-react/no-use-context": "warn",
"@eslint-react/no-useless-forward-ref": "warn",
"@eslint-react/no-useless-fragment": "off",
"@eslint-react/prefer-destructuring-assignment": "off",
"@eslint-react/prefer-namespace-import": "off",
"@eslint-react/prefer-read-only-props": "off",
"@eslint-react/prefer-use-state-lazy-initialization": "warn",
} as const satisfies Record<string, RuleConfig>;

Expand Down
11 changes: 11 additions & 0 deletions packages/plugins/eslint-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import * as offConfig from "./configs/off";
import * as recommendedConfig from "./configs/recommended";
import * as recommendedTypeCheckedConfig from "./configs/recommended-type-checked";
import * as recommendedTypeScriptConfig from "./configs/recommended-typescript";
import * as strictTypeCheckedConfig from "./configs/strict-type-checked";
import * as strictTypescriptConfig from "./configs/strict-typescript";
import * as xConfig from "./configs/x";

import { padKeysLeft } from "./utils";

const plugin: CompatiblePlugin = {
Expand Down Expand Up @@ -96,6 +99,14 @@ export default {
* Same as the `recommended` preset but disables rules that can be enforced by TypeScript
*/
["recommended-typescript"]: recommendedTypeScriptConfig,
/**
* More strict version of the `recommended-type-checked` preset
*/
["strict-type-checked"]: strictTypeCheckedConfig,
/**
* More strict version of the `recommended-typescript` preset
*/
["strict-typescript"]: strictTypescriptConfig,
/**
* Enable rules for `"react"`
*/
Expand Down
Loading