jsx-eslint /eslint-plugin-react

React-specific linting rules for ESLint

★ 9,292⑂ 2,737👁 79⑃ 1,475● 2,597▤ 200
JavaScriptMITCreated 2014-12-15
Download: v7.37.5v7.37.5 ↓7.37.52025-04-03
+1
Daily
9,292
stars
2,737
forks
79
watchers
1,475
prs
2,597
issues
200
releases

README

eslint-plugin-react [![Version Badge][npm-version-svg]][package-url]

===================

[![github actions][actions-image]][actions-url]
[![Maintenance Status][status-image]][status-url]
[![NPM version][npm-image]][npm-url]
[![Tidelift][tidelift-image]][tidelift-url]

React specific linting rules for eslint

 Installation

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


It is also possible to install ESLint globally rather than locally (using npm install -g eslint). However, this is not recommended, and any plugins or shareable configs that you use must be installed locally in either case.

 Configuration (legacy: .eslintrc) 

Use our preset to get reasonable defaults:

json
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended"
  ]


If you are using the new JSX transform from React 17, extend react/jsx-runtime in your eslint config (add "plugin:react/jsx-runtime" to "extends") to disable the relevant rules.

You should also specify settings that will be shared across all the plugin rules. (More about eslint shared settings)

json5
{
  "settings": {
    "react": {
      "createClass": "createReactClass", // Regex for Component Factory to use,
                                         // default to "createReactClass"
      "pragma": "React",  // Pragma to use, default to "React"
      "fragment": "Fragment",  // Fragment to use (may be a property of ), default to "Fragment"
      "version": "detect", // React version. "detect" automatically picks the version you have installed.
                           // You can also use 16.0, 16.3, etc, if you want to override the detected value.
                           // Defaults to the "defaultVersion" setting and warns if missing, and to "detect" in the future
      "defaultVersion": "", // Default React version to use when the version you have installed cannot be detected.
                            // If not provided, defaults to the latest React version.
      "flowVersion": "0.53" // Flow version
    },
    "propWrapperFunctions": [
        // The names of any function used to wrap propTypes, e.g. forbidExtraProps. If this isn't set, any propTypes wrapped in a function will be skipped.
        "forbidExtraProps",
        {"property": "freeze", "object": "Object"},
        {"property": "myFavoriteWrapper"},
        // for rules that check exact prop wrappers
        {"property": "forbidExtraProps", "exact": true}
    ],
    "componentWrapperFunctions": [
        // The name of any function used to wrap components, e.g. Mobx observer function. If this isn't set, components wrapped by these functions will be skipped.
        "observer", // property
        {"property": "styled"}, // object is optional
        {"property": "observer", "object": "Mobx"},
        {"property": "observer", "object": ""} // sets object to whatever value settings.react.pragma is set to
    ],
    "formComponents": [
      // Components used as alternatives to  for forms, eg. 
      "CustomForm",
   

Top issues

Latest release

v7.37.5 v7.37.5 2025-04-03
Fixed
 [no-unknown-property]: allow shadow root attrs on  ([3912][] @ljharb)
 [prop-types]: support ComponentPropsWithRef from a namespace import ([3651][] @corydeppen)
 [jsx-no-constructed-context-values]: detect constructed context values in React 19  usage ([3910][] @TildaDares)
 [no-unknown-property]: allow transform-origin on rect ([3914][] @ljharb)

 Changed
 [Docs] [button-has-type]: clean up phrasing ([3909][] @hamirmahal)

[3651]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3651
[3909]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3909
[3910]: https://g

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON