react/compiler/packages/eslint-plugin-react-compiler
Joseph Savona 1324e1bb1f
[compiler] Cleanup and enable validateNoVoidUseMemo (#34882)
This is a great validation, so let's enable by default. Changes:
* Move the validation logic into ValidateUseMemo alongside the new check
that the useMemo result is used
* Update the lint description
* Make the void memo errors lint-only, they don't require us to skip
compilation (as evidenced by the fact that we've had this validation
off)

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34882).
* #34855
* __->__ #34882
2025-10-16 13:08:57 -07:00
..
__tests__ [compiler] Cleanup and enable validateNoVoidUseMemo (#34882) 2025-10-16 13:08:57 -07:00
src [compiler] Setup RecommendedLatest preset (#34782) 2025-10-08 15:45:22 -04:00
babel.config.js [compiler] Remove @babel/plugin-proposal-private-methods (#34715) 2025-10-03 09:13:55 -07:00
package.json [compiler] improve zod v3 backwards compat (#34877) 2025-10-16 09:46:55 -07:00
README.md docs(eslint-plugin-react-compiler): fix typo (#32149) 2025-01-22 16:59:50 +01:00
tsconfig.json [compiler] Migrate compiler packages to tsup (#32550) 2025-03-07 16:41:55 -05:00
tsup.config.ts [compiler] improve zod v3 backwards compat (#34877) 2025-10-16 09:46:55 -07:00

eslint-plugin-react-compiler

ESLint plugin surfacing problematic React code found by the React compiler.

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-react-compiler:

npm install eslint-plugin-react-compiler --save-dev

Usage

Flat config

Edit your eslint 8+ config (for example eslint.config.mjs) with the recommended configuration:

+ 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.configs.recommended    
]

Legacy config (.eslintrc)

Add react-compiler to the plugins section of your configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "react-compiler"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "react-compiler/react-compiler": "error"
    }
}

Rules

TODO: Run eslint-doc-generator to generate the rules list.