ESLint Plugin for React Compiler

19.1.0-rc.2 · active · verified Sun Apr 19

The `eslint-plugin-react-compiler` is an ESLint plugin designed to integrate with the experimental React Compiler (internally known as React Forget). Its primary function is to surface and display errors, warnings, and suggestions generated by the compiler directly within the developer's integrated development environment (IDE) or during continuous integration (CI) builds. Currently at version `19.1.0-rc.2`, it operates as a release candidate, indicating active development and potential for API instability. The plugin is a critical tool for developers experimenting with the React Compiler, providing immediate feedback on compilation issues and guiding them towards code patterns compatible with automatic memoization and optimization. Given its close tie to an experimental React feature, its release cadence is likely irregular and directly linked to the React Compiler's own development milestones, focusing on correctness and performance improvements. It differentiates itself by being the official mechanism to lint against compiler-specific issues, a function not covered by generic ESLint rules or other React-specific ESLint plugins.

Common errors

Warnings

Install

Imports

Quickstart

This configuration snippet demonstrates how to set up ESLint to utilize `eslint-plugin-react-compiler` within a React project. It includes the plugin in the `plugins` array and extends its recommended ruleset, allowing ESLint to detect and report errors, warnings, and suggestions generated by the experimental React Compiler directly in your development environment.

module.exports = {
  root: true,
  env: {
    browser: true,
    es2020: true,
    node: true
  },
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true
    }
  },
  settings: {
    react: {
      version: 'detect' // Automatically detect React version
    }
  },
  extends: [
    'eslint:recommended',
    'plugin:react/recommended',
    'plugin:react/jsx-runtime',
    'plugin:react-compiler/recommended' // Enable recommended rules from the compiler plugin
  ],
  plugins: [
    'react',
    'react-compiler' // Register the plugin
  ],
  rules: {
    // Example: Override or add specific rules if needed
    // 'react-compiler/no-render-prop-expression': 'warn'
  }
};

view raw JSON →