react/compiler/packages/eslint-plugin-react-compiler
Lauren Tan 113c8e7f72 [compiler:eslint] Don't crash if hermes parser fails to parse
Eslint rules should never throw, so if we fail to parse with Babel or
Hermes, we should just ignore the error. This should fix issues such as
trying to run the eslint rule on non tsx|ts|jsx|js files, Hermes parser
not supporting certain JS syntax, etc.

I didn't add a test for this as our eslint-rule-tester config uses
hermes-eslint parser, so it wasn't possible to add a top level await as
it would crash hermes-eslint before our rule was triggered. Similarly I
couldn't add a test for non-JS files as it would not be parseable by
hermes-eslint.

Fixes #29107

ghstack-source-id: 60afcdb89ab4a8d2e4697cc50c5490803e7cbeac
Pull Request resolved: https://github.com/facebook/react/pull/29631
2024-06-01 08:04:41 +09:00
..
__tests__ [compiler:eslint] Fix false positive with TS type param syntax 2024-05-15 15:44:21 -07:00
src [compiler:eslint] Don't crash if hermes parser fails to parse 2024-06-01 08:04:41 +09:00
babel.config.js Rename eslint-plugin-react-forget to eslint-plugin-react-compiler 2024-01-16 17:36:37 -05:00
package.json Bump version to 0.0.0-experimental-a97cca1-20240529 2024-05-29 12:01:35 +09:00
README.md [React Compiler] Fix rule name for ESLint plugin (#29096) 2024-05-16 12:36:22 -04:00
rollup.config.js Standardize on banner2 plugin 2024-04-02 12:13:41 -04:00
tsconfig.json Remove comments in builds 2024-04-02 10:32:24 -04: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

Add react-compiler to the plugins section of your .eslintrc 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.