diff --git a/examples/next/eslint.config.js b/examples/next/eslint.config.js index 7bad9f524..a0d380874 100644 --- a/examples/next/eslint.config.js +++ b/examples/next/eslint.config.js @@ -42,7 +42,7 @@ export default defineConfig([ { files: TSCONFIG.include, extends: [ - eslintReact.configs["strict-type-checked"], + eslintReact.configs["strict-typescript"], eslintPluginReactRefresh.configs.recommended, eslintPluginReactHooks.configs.flat["recommended-latest"] ?? [], ], diff --git a/examples/react-dom-js/eslint.config.js b/examples/react-dom-js/eslint.config.js index 6ccd99170..9524b89db 100644 --- a/examples/react-dom-js/eslint.config.js +++ b/examples/react-dom-js/eslint.config.js @@ -51,7 +51,7 @@ export default defineConfig([ { files: JSCONFIG_APP.include, extends: [ - eslintReact.configs.recommended, + eslintReact.configs.strict, eslintPluginReactHooks.configs.flat["recommended-latest"] ?? [], eslintPluginReactRefresh.configs.recommended, ], diff --git a/packages/plugins/eslint-plugin-react-x/src/configs/strict.ts b/packages/plugins/eslint-plugin-react-x/src/configs/strict.ts index 6bfff7375..1143c7763 100644 --- a/packages/plugins/eslint-plugin-react-x/src/configs/strict.ts +++ b/packages/plugins/eslint-plugin-react-x/src/configs/strict.ts @@ -15,7 +15,6 @@ export const rules = { "react-x/no-unstable-context-value": "warn", "react-x/no-unstable-default-props": "warn", "react-x/no-unused-class-component-members": "warn", - "react-x/no-unused-props": "warn", "react-x/no-unused-state": "warn", "react-x/no-useless-fragment": "warn", "react-x/prefer-destructuring-assignment": "warn", diff --git a/packages/plugins/eslint-plugin-react-x/src/index.ts b/packages/plugins/eslint-plugin-react-x/src/index.ts index baa65c137..2f93144eb 100644 --- a/packages/plugins/eslint-plugin-react-x/src/index.ts +++ b/packages/plugins/eslint-plugin-react-x/src/index.ts @@ -1,8 +1,13 @@ +/* eslint-disable perfectionist/sort-objects */ import { getConfigAdapters } from "@eslint-react/shared"; import * as recommendedConfig from "./configs/recommended"; import * as recommendedTypeCheckedConfig from "./configs/recommended-type-checked"; import * as recommendedTypeScriptConfig from "./configs/recommended-typescript"; +import * as strictConfig from "./configs/strict"; +import * as strictTypeCheckedConfig from "./configs/strict-type-checked"; +import * as strictTypeScriptConfig from "./configs/strict-typescript"; + import { plugin } from "./plugin"; const { toFlatConfig } = getConfigAdapters("react-x", plugin); @@ -10,8 +15,29 @@ const { toFlatConfig } = getConfigAdapters("react-x", plugin); export default { ...plugin, configs: { + /** + * Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects + */ ["recommended"]: toFlatConfig(recommendedConfig), - ["recommended-type-checked"]: toFlatConfig(recommendedTypeCheckedConfig), + /** + * Same as the `recommended` preset but disables rules that can be enforced by TypeScript + */ ["recommended-typescript"]: toFlatConfig(recommendedTypeScriptConfig), + /** + * Same as the `recommended-typescript` preset but enables additional rules that require type information + */ + ["recommended-type-checked"]: toFlatConfig(recommendedTypeCheckedConfig), + /** + * More strict version of the `recommended` preset + */ + ["strict"]: toFlatConfig(strictConfig), + /** + * Same as the `strict` preset but enables additional rules that require type information + */ + ["strict-typescript"]: toFlatConfig(strictTypeScriptConfig), + /** + * Same as the `strict-typescript` preset but enables additional rules that require type information + */ + ["strict-type-checked"]: toFlatConfig(strictTypeCheckedConfig), }, }; diff --git a/packages/plugins/eslint-plugin/README.md b/packages/plugins/eslint-plugin/README.md index e4ce218ea..f268d8494 100644 --- a/packages/plugins/eslint-plugin/README.md +++ b/packages/plugins/eslint-plugin/README.md @@ -183,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/fix-strict-config-export/.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/fix-strict-config-export/LICENSE) file for details. diff --git a/packages/plugins/eslint-plugin/src/configs/strict.ts b/packages/plugins/eslint-plugin/src/configs/strict.ts index 84eadad4e..131e56bc6 100644 --- a/packages/plugins/eslint-plugin/src/configs/strict.ts +++ b/packages/plugins/eslint-plugin/src/configs/strict.ts @@ -15,7 +15,6 @@ export const rules = { "@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", diff --git a/packages/plugins/eslint-plugin/src/index.ts b/packages/plugins/eslint-plugin/src/index.ts index 5bbb1f56d..68d2899ed 100644 --- a/packages/plugins/eslint-plugin/src/index.ts +++ b/packages/plugins/eslint-plugin/src/index.ts @@ -21,8 +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 strictConfig from "./configs/strict"; import * as strictTypeCheckedConfig from "./configs/strict-type-checked"; import * as strictTypescriptConfig from "./configs/strict-typescript"; +import * as webApiConfig from "./configs/web-api"; import * as xConfig from "./configs/x"; import { padKeysLeft } from "./utils"; @@ -46,7 +48,7 @@ export default { ...plugin, configs: { /** - * Enable all rules in this plugin + * Enable all applicable rules from this plugin */ ["all"]: allConfig, /** @@ -100,13 +102,21 @@ export default { */ ["recommended-typescript"]: recommendedTypeScriptConfig, /** - * More strict version of the `recommended-type-checked` preset + * More strict version of the `recommended` preset + */ + ["strict"]: strictConfig, + /** + * Same as the `strict-typescript` preset but enables additional rules that require type information */ ["strict-type-checked"]: strictTypeCheckedConfig, /** - * More strict version of the `recommended-typescript` preset + * Same as the `strict` preset but disables rules that can be enforced by TypeScript */ ["strict-typescript"]: strictTypescriptConfig, + /** + * Enable rules for interacting with Web APIs + */ + ["web-api"]: webApiConfig, /** * Enable rules for `"react"` */