Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support eslint 8+ flat plugin syntax out of the box for eslint-plugin-react-compiler #32120

Merged
merged 1 commit into from
Jan 18, 2025
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
19 changes: 18 additions & 1 deletion compiler/packages/eslint-plugin-react-compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
14 changes: 14 additions & 0 deletions compiler/packages/eslint-plugin-react-compiler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
},
};
Loading