ESLint Plugin
Theeslint-plugin-react-compiler package provides ESLint rules that surface problematic React code found by the React Compiler, helping you catch violations of the Rules of React before compilation.
Installation
Configuration
Flat Config (ESLint 8+)
For modern ESLint flat config:eslint.config.mjs
Using Recommended Config
eslint.config.mjs
Legacy Config (.eslintrc)
For.eslintrc configuration:
Rule Configuration
Error Level
Configure the rule severity:Rule Options
The rule accepts the same configuration options as the Babel plugin:eslint.config.mjs
What It Checks
The ESLint plugin runs the React Compiler on your code and reports React-specific errors. It validates:Rules of Hooks
setState During Render
Ref Access During Render
Exhaustive Dependencies
Component Mutations
Integration with Existing Setup
With eslint-plugin-react-hooks
Use both plugins together:eslint.config.mjs
With TypeScript
eslint.config.mjs
File-Based Configuration
eslint.config.mjs
Editor Integration
VS Code
Install the ESLint extension:- Install ESLint extension
- Add to
.vscode/settings.json:
.vscode/settings.json
WebStorm / IntelliJ IDEA
- Go to Settings → Languages & Frameworks → JavaScript → Code Quality Tools → ESLint
- Enable “Automatic ESLint configuration”
- Set “Run eslint —fix on save”
Vim / Neovim
Use ALE or coc-eslint:.vimrc
CI/CD Integration
GitHub Actions
.github/workflows/lint.yml
GitLab CI
.gitlab-ci.yml
Pre-commit Hook
Usehusky and lint-staged:
Troubleshooting
”No files matching the pattern were found”
Ensure your ESLint config includes the correct file patterns:eslint.config.mjs
“Failed to load plugin ‘react-compiler’”
Verify the plugin is installed:High Memory Usage
For large codebases, increase Node memory:package.json
Slow Linting
Use ESLint cache:package.json:
Ignoring Violations
File-Level
Line-Level
.eslintignore
.eslintignore
Best Practices
Gradual Adoption
-
Start with warnings:
- Fix violations incrementally
-
Switch to errors:
Team Workflow
- Local Development: Show warnings in editor
- Pre-commit: Block commits with errors
- CI/CD: Fail builds on errors
- Code Review: Require fixes before merge
Documentation
Document exceptions:Next Steps
Configuration
Configure compiler validation options
Babel Plugin
Set up code transformation
How It Works
Understand the validation process
Contributing
Contribute to the ESLint plugin