Skip to main content

ESLint Plugin

The eslint-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
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:
  1. Install ESLint extension
  2. Add to .vscode/settings.json:
.vscode/settings.json

WebStorm / IntelliJ IDEA

  1. Go to Settings → Languages & Frameworks → JavaScript → Code Quality Tools → ESLint
  2. Enable “Automatic ESLint configuration”
  3. 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

Use husky 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:
Reinstall if necessary:

High Memory Usage

For large codebases, increase Node memory:
package.json

Slow Linting

Use ESLint cache:
Or in package.json:

Ignoring Violations

File-Level

Line-Level

.eslintignore

.eslintignore

Best Practices

Gradual Adoption

  1. Start with warnings:
  2. Fix violations incrementally
  3. Switch to errors:

Team Workflow

  1. Local Development: Show warnings in editor
  2. Pre-commit: Block commits with errors
  3. CI/CD: Fail builds on errors
  4. 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