diff --git a/compiler/packages/eslint-plugin-react-compiler/README.md b/compiler/packages/eslint-plugin-react-compiler/README.md index 1dc11454f2de7..cc70679383690 100644 --- a/compiler/packages/eslint-plugin-react-compiler/README.md +++ b/compiler/packages/eslint-plugin-react-compiler/README.md @@ -18,7 +18,24 @@ npm install eslint-plugin-react-compiler --save-dev ## Usage -Add `react-compiler` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix: +### Flat config + +Edit your eslint 8+ config (for example `eslint.config.mjs`) with the recommended configuration: + +```diff ++ import reactCompiler from "eslint-plugin-react-compiler" +import react from "eslint-plugin-react" + +export default [ + // Your existing config + { ...pluginReact.configs.flat.recommended, settings: { react: { version: "detect" } } }, ++ reactCompiler.config.recommended +] +``` + +### Legacy config (`.eslintrc`) + +Add `react-compiler` to the plugins section of your configuration file. You can omit the `eslint-plugin-` prefix: ```json { diff --git a/compiler/packages/eslint-plugin-react-compiler/src/index.ts b/compiler/packages/eslint-plugin-react-compiler/src/index.ts index a7349257516b5..103cdbbbd3245 100644 --- a/compiler/packages/eslint-plugin-react-compiler/src/index.ts +++ b/compiler/packages/eslint-plugin-react-compiler/src/index.ts @@ -11,4 +11,18 @@ module.exports = { rules: { 'react-compiler': ReactCompilerRule, }, + configs: { + recommended: { + plugins: { + 'react-compiler': { + rules: { + 'react-compiler': ReactCompilerRule, + }, + }, + }, + rules: { + 'react-compiler/react-compiler': 'error', + }, + }, + }, };