From ac584743b2f5a020869b58548e4cb513cb0381ff Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Sat, 18 Jan 2025 19:53:08 +0000 Subject: [PATCH] Support eslint 8+ plugin syntax out of the box --- .../eslint-plugin-react-compiler/README.md | 19 ++++++++++++++++++- .../eslint-plugin-react-compiler/src/index.ts | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) 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', + }, + }, + }, };