Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-plugin-react

jsx-eslint63.6mMIT7.37.4TypeScript support: included

React specific linting rules for ESLint

eslint, eslint-plugin, eslintplugin, react

readme

eslint-plugin-react Version Badge

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

github actions Maintenance Status NPM version Tidelift

React specific linting rules for eslint

Installation

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:

  "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)

{
  "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 <pragma>), 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": "<pragma>"} // sets `object` to whatever value `settings.react.pragma` is set to
    ],
    "formComponents": [
      // Components used as alternatives to <form> for forms, eg. <Form endpoint={ url } />
      "CustomForm",
      {"name": "SimpleForm", "formAttribute": "endpoint"},
      {"name": "Form", "formAttribute": ["registerEndpoint", "loginEndpoint"]}, // allows specifying multiple properties if necessary
    ],
    "linkComponents": [
      // Components used as alternatives to <a> for linking, eg. <Link to={ url } />
      "Hyperlink",
      {"name": "MyLink", "linkAttribute": "to"},
      {"name": "Link", "linkAttribute": ["to", "href"]}, // allows specifying multiple properties if necessary
    ]
  }
}

If you do not use a preset you will need to specify individual rules and add extra configuration.

Add "react" to the plugins section.

{
  "plugins": [
    "react"
  ]
}

Enable JSX support.

With eslint 2+

{
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    }
  }
}

Enable the rules that you would like to use.

  "rules": {
    "react/jsx-uses-react": "error",
    "react/jsx-uses-vars": "error",
  }

Shareable configs

This plugin exports a recommended configuration that enforces React good practices.

To enable this configuration use the extends property in your .eslintrc config file:

{
  "extends": ["eslint:recommended", "plugin:react/recommended"]
}

See eslint documentation for more information about extending configuration files.

All

This plugin also exports an all configuration that includes every available rule. This pairs well with the eslint:all rule.

{
  "plugins": [
    "react"
  ],
  "extends": ["eslint:all", "plugin:react/all"]
}

Note: These configurations will import eslint-plugin-react and enable JSX in parser options.

Configuration (new: eslint.config.js)

From v8.21.0, eslint announced a new config system. In the new system, .eslintrc* is no longer used. eslint.config.js would be the default config file name. In eslint v8, the legacy system (.eslintrc*) would still be supported, while in eslint v9, only the new system would be supported.

And from v8.23.0, eslint CLI starts to look up eslint.config.js. So, if your eslint is >=8.23.0, you're 100% ready to use the new config system.

You might want to check out the official blog posts,

and the official docs.

Plugin

The default export of eslint-plugin-react is a plugin object.

const react = require('eslint-plugin-react');
const globals = require('globals');

module.exports = [
  …
  {
    files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
    plugins: {
      react,
    },
    languageOptions: {
      parserOptions: {
        ecmaFeatures: {
          jsx: true,
        },
      },
      globals: {
        ...globals.browser,
      },
    },
    rules: {
      // ... any rules you want
      'react/jsx-uses-react': 'error',
      'react/jsx-uses-vars': 'error',
     },
    // ... others are omitted for brevity
  },
  …
];

Configuring shared settings

Refer to the official docs.

The schema of the settings.react object would be identical to that of what's already described above in the legacy config section.

Flat Configs

This plugin exports 3 flat configs:

  • flat.all
  • flat.recommended
  • flat['jsx-runtime']

The flat configs are available via the root plugin import. They will configure the plugin under the react/ namespace and enable JSX in languageOptions.parserOptions.

const reactPlugin = require('eslint-plugin-react');

module.exports = [
  …
  reactPlugin.configs.flat.recommended, // This is not a plugin object, but a shareable config object
  reactPlugin.configs.flat['jsx-runtime'], // Add this if you are using React 17+
  …
];

You can of course add/override some properties.

Note: Our shareable configs does not preconfigure files or languageOptions.globals. For most of the cases, you probably want to configure some properties by yourself.

const reactPlugin = require('eslint-plugin-react');
const globals = require('globals');

module.exports = [
  …
  {
    files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
    ...reactPlugin.configs.flat.recommended,
    languageOptions: {
      ...reactPlugin.configs.flat.recommended.languageOptions,
      globals: {
        ...globals.serviceworker,
        ...globals.browser,
      },
    },
  },
  …
];

The above example is same as the example below, as the new config system is based on chaining.

const reactPlugin = require('eslint-plugin-react');
const globals = require('globals');

module.exports = [
  …
  {
    files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
    ...reactPlugin.configs.flat.recommended,
  },
  {
    files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
    languageOptions: {
      globals: {
        ...globals.serviceworker,
        ...globals.browser,
      },
    },
  },
  …
];

List of supported rules

💼 Configurations enabled in.\ 🚫 Configurations disabled in.\ 🏃 Set in the jsx-runtime configuration.\ ☑️ Set in the recommended configuration.\ 🔧 Automatically fixable by the --fix CLI option.\ 💡 Manually fixable by editor suggestions.\ ❌ Deprecated.

Name Description 💼 🚫 🔧 💡
boolean-prop-naming Enforces consistent naming for boolean props | |
button-has-type Disallow usage of button elements without an explicit type attribute | |
checked-requires-onchange-or-readonly Enforce using onChange or readonly attribute when checked is used | |
default-props-match-prop-types Enforce all defaultProps have a corresponding non-required PropType | |
destructuring-assignment Enforce consistent usage of destructuring assignment of props, state, and context | 🔧 |
display-name Disallow missing displayName in a React component definition ☑️ | |
forbid-component-props Disallow certain props on components | |
forbid-dom-props Disallow certain props on DOM Nodes | |
forbid-elements Disallow certain elements | |
forbid-foreign-prop-types Disallow using another component's propTypes | |
forbid-prop-types Disallow certain propTypes | |
forward-ref-uses-ref Require all forwardRef components include a ref parameter | | 💡
function-component-definition Enforce a specific function type for function components | 🔧 |
hook-use-state Ensure destructuring and symmetric naming of useState hook value and setter variables | | 💡
iframe-missing-sandbox Enforce sandbox attribute on iframe elements | |
jsx-boolean-value Enforce boolean attributes notation in JSX | 🔧 |
jsx-child-element-spacing Enforce or disallow spaces inside of curly braces in JSX attributes and expressions | |
jsx-closing-bracket-location Enforce closing bracket location in JSX | 🔧 |
jsx-closing-tag-location Enforce closing tag location for multiline JSX | 🔧 |
jsx-curly-brace-presence Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes | 🔧 |
jsx-curly-newline Enforce consistent linebreaks in curly braces in JSX attributes and expressions | 🔧 |
jsx-curly-spacing Enforce or disallow spaces inside of curly braces in JSX attributes and expressions | 🔧 |
jsx-equals-spacing Enforce or disallow spaces around equal signs in JSX attributes | 🔧 |
jsx-filename-extension Disallow file extensions that may contain JSX | |
jsx-first-prop-new-line Enforce proper position of the first property in JSX | 🔧 |
jsx-fragments Enforce shorthand or standard form for React fragments | 🔧 |
jsx-handler-names Enforce event handler naming conventions in JSX | |
jsx-indent Enforce JSX indentation | 🔧 |
jsx-indent-props Enforce props indentation in JSX | 🔧 |
jsx-key Disallow missing key props in iterators/collection literals ☑️ | |
jsx-max-depth Enforce JSX maximum depth | |
jsx-max-props-per-line Enforce maximum of props on a single line in JSX | 🔧 |
jsx-newline Require or prevent a new line after jsx elements and expressions. | 🔧 |
jsx-no-bind Disallow .bind() or arrow functions in JSX props | |
jsx-no-comment-textnodes Disallow comments from being inserted as text nodes ☑️ | |
jsx-no-constructed-context-values Disallows JSX context provider values from taking values that will cause needless rerenders | |
jsx-no-duplicate-props Disallow duplicate properties in JSX ☑️ | |
jsx-no-leaked-render Disallow problematic leaked values from being rendered | 🔧 |
jsx-no-literals Disallow usage of string literals in JSX | |
jsx-no-script-url Disallow usage of javascript: URLs | |
jsx-no-target-blank Disallow target="_blank" attribute without rel="noreferrer" ☑️ | 🔧 |
jsx-no-undef Disallow undeclared variables in JSX ☑️ | |
jsx-no-useless-fragment Disallow unnecessary fragments | 🔧 |
jsx-one-expression-per-line Require one JSX element per line | 🔧 |
jsx-pascal-case Enforce PascalCase for user-defined JSX components | |
jsx-props-no-multi-spaces Disallow multiple spaces between inline JSX props | 🔧 |
jsx-props-no-spread-multi Disallow JSX prop spreading the same identifier multiple times | |
jsx-props-no-spreading Disallow JSX prop spreading | |
jsx-sort-default-props Enforce defaultProps declarations alphabetical sorting | |
jsx-sort-props Enforce props alphabetical sorting | 🔧 |
jsx-space-before-closing Enforce spacing before closing bracket in JSX | 🔧 | ❌
jsx-tag-spacing Enforce whitespace in and around the JSX opening and closing brackets | 🔧 |
jsx-uses-react Disallow React to be incorrectly marked as unused ☑️ 🏃 |
jsx-uses-vars Disallow variables used in JSX to be incorrectly marked as unused ☑️ | |
jsx-wrap-multilines Disallow missing parentheses around multiline JSX | 🔧 |
no-access-state-in-setstate Disallow when this.state is accessed within setState | |
no-adjacent-inline-elements Disallow adjacent inline elements not separated by whitespace. | |
no-array-index-key Disallow usage of Array index in keys | |
no-arrow-function-lifecycle Lifecycle methods should be methods on the prototype, not class fields | 🔧 |
no-children-prop Disallow passing of children as props ☑️ | |
no-danger Disallow usage of dangerous JSX properties | |
no-danger-with-children Disallow when a DOM element is using both children and dangerouslySetInnerHTML ☑️ | |
no-deprecated Disallow usage of deprecated methods ☑️ | |
no-did-mount-set-state Disallow usage of setState in componentDidMount | |
no-did-update-set-state Disallow usage of setState in componentDidUpdate | |
no-direct-mutation-state Disallow direct mutation of this.state ☑️ | |
no-find-dom-node Disallow usage of findDOMNode ☑️ | |
no-invalid-html-attribute Disallow usage of invalid attributes | | 💡
no-is-mounted Disallow usage of isMounted ☑️ | |
no-multi-comp Disallow multiple component definition per file | |
no-namespace Enforce that namespaces are not used in React elements | |
no-object-type-as-default-prop Disallow usage of referential-type variables as default param in functional component | |
no-redundant-should-component-update Disallow usage of shouldComponentUpdate when extending React.PureComponent | |
no-render-return-value Disallow usage of the return value of ReactDOM.render ☑️ | |
no-set-state Disallow usage of setState | |
no-string-refs Disallow using string references ☑️ | |
no-this-in-sfc Disallow this from being used in stateless functional components | |
no-typos Disallow common typos | |
no-unescaped-entities Disallow unescaped HTML entities from appearing in markup ☑️ | 💡
no-unknown-property Disallow usage of unknown DOM property ☑️ | 🔧 |
no-unsafe Disallow usage of unsafe lifecycle methods | ☑️ |
no-unstable-nested-components Disallow creating unstable components inside components | |
no-unused-class-component-methods Disallow declaring unused methods of component class | |
no-unused-prop-types Disallow definitions of unused propTypes | |
no-unused-state Disallow definitions of unused state | |
no-will-update-set-state Disallow usage of setState in componentWillUpdate | |
prefer-es6-class Enforce ES5 or ES6 class for React Components | |
prefer-exact-props Prefer exact proptype definitions | |
prefer-read-only-props Enforce that props are read-only | 🔧 |
prefer-stateless-function Enforce stateless components to be written as a pure function | |
prop-types Disallow missing props validation in a React component definition ☑️ | |
react-in-jsx-scope Disallow missing React when using JSX ☑️ 🏃 |
require-default-props Enforce a defaultProps definition for every prop that is not a required prop | |
require-optimization Enforce React components to have a shouldComponentUpdate method | |
require-render-return Enforce ES5 or ES6 class for returning value in render function ☑️ | |
self-closing-comp Disallow extra closing tags for components without children | 🔧 |
sort-comp Enforce component methods order | |
sort-default-props Enforce defaultProps declarations alphabetical sorting | |
sort-prop-types Enforce propTypes declarations alphabetical sorting | 🔧 |
state-in-constructor Enforce class component state initialization style | |
static-property-placement Enforces where React component static properties should be positioned. | |
style-prop-object Enforce style prop value is an object | |
void-dom-elements-no-children Disallow void DOM elements (e.g. <img />, <br />) from receiving children | |

Other useful plugins

License

eslint-plugin-react is licensed under the MIT License.

changelog

Change Log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning. This change log adheres to standards from Keep a CHANGELOG.

Unreleased

7.37.4 - 2025.01.12

Fixed

  • no-unknown-property: support onBeforeToggle, popoverTarget, popoverTargetAction attributes (#3865 @acusti)
  • [types] fix types of flat configs (#3874 @ljharb)

7.37.3 - 2024.12.23

Fixed

  • no-danger: avoid a crash on a nested component name (#3833 @ljharb)
  • [Fix] types: correct generated type declaration (#3840 @ocavue)
  • no-unknown-property: support precedence prop in react 19 (#3829 @acusti)
  • prop-types: props missing in validation when using generic types from a namespace import (#3859 @rbondoc96)

Changed

7.37.2 - 2024.10.22

Fixed

Changed

7.37.1 - 2024.10.01

Fixed

  • [meta] do not npmignore d.ts files (#3836 @ljharb)

Changed

  • [readme] Fix shared settings link (#3834 @MgenGlder)

7.37.0 - 2024.09.26

Added

Changed

  • [readme] flat config example for react 17+ (#3824 @GabenGar)

7.36.1 - 2024.09.12

Fixed

7.36.0 - 2024.09.12

Added

Fixed

Changed

  • [Tests] add @typescript-eslint/parser v6 (#3629 @HenryBrown0)
  • [Tests] add @typescript-eslint/parser v7 and v8 (#3629 @hampustagerud)
  • [Docs] no-danger: update broken link (#3817 @lucasrmendonca)
  • [types] add jsdoc type annotations (#3731 @y-hsgw)
  • [Tests] button-has-type: add test case with spread (#3731 @y-hsgw)

7.35.2 - 2024.09.03

Fixed

7.35.1 - 2024.09.02

Fixed

7.35.0 - 2024.07.19

Added

Fixed

Changed

  • [Refactor] variableUtil: Avoid creating a single flat variable scope for each lookup (#3782 @DanielRosenwasser)

7.34.4 - 2024.07.13

Fixed

  • prop-types: fix className missing in prop validation false negative (#3749 @akulsr0)
  • sort-prop-types: Check for undefined before accessing node.typeAnnotation.typeAnnotation (#3779 @tylerlaprade)

7.34.3 - 2024.06.18

Fixed

7.34.2 - 2024.05.24

Fixed

Changed

  • [Refactor] create various eslint utils to fix eslint deprecations (#3759 @mdjermanovic, @ljharb)

7.34.1 - 2024.03.15

Fixed

Changed

7.34.0 - 2024.03.03

Added

Fixed

Changed

7.33.2 - 2023.08.15

Fixed

  • no-deprecated: prevent false positive on commonjs import (#3614 @akulsr0)
  • no-unsafe: report on the method instead of the entire component (@ljharb)
  • no-deprecated: report on the destructured property instead of the entire variable declarator (@ljharb)
  • no-deprecated: report on the imported specifier instead of the entire import statement (@ljharb)
  • no-invalid-html-attribute: report more granularly (@ljharb)

7.33.1 - 2023.07.29

Fixed

7.33.0 - 2023.07.19

Added

Fixed

Changed

7.32.2 - 2023.01.28

Fixed

7.32.1 - 2023.01.16

Fixed

  • prevent circular dependency in index and "all" config (#3519 @ljharb)
  • destructuring-assignment: do not force destructuring of optionally chained properties (#3520 @ljharb)

7.32.0 - 2023.01.10

Added

Fixed

Changed

  • [Docs] jsx-no-leaked-render: Remove mentions of empty strings for React 18 (#3468 @karlhorky)
  • [Docs] update eslint-doc-generator to v1.0.0 (#3499 @bmish)
  • [meta] add issue template (#3483 @ROSSROSALES)
  • [Docs] Use emoji for jsx-runtime config and config file for eslint-doc-generator (#3504 @bmish)
  • [Docs] prefer-exact-props: fix example flow syntax (#3510 @smackfu)
  • [Perf] use anyOf instead of oneOf (@ljharb @remcohaszing)

7.31.11 - 2022.11.17

Fixed

Changed

  • [Perf] component detection: improve performance by avoiding traversing parents unnecessarily (#3459 @golopot)
  • [Docs] forbid-component-props: inclusive language w/ allowlist (#3473 @AndersDJohnson)
  • [Docs] automate doc generation with eslint-doc-generator (#3469 @bmish)

7.31.10 - 2022.10.10

Fixed

7.31.9 - 2022.10.09

Fixed

Changed

7.31.8 - 2022.09.08

Fixed

Changed

  • [meta] npmignore markdownlint config (#3413 @jorrit)

7.31.7 - 2022.09.05

Fixed

7.31.6 - 2022.09.04

Fixed

Changed

  • [Docs] no-unknown-property: add a mention about using ignores properties with libraries that add props (#3390 @sjarva)

7.31.5 - 2022.09.03

Fixed

7.31.4 - 2022.09.03

Fixed

7.31.3 - 2022.09.02

Fixed

7.31.2 - 2022.09.02

Fixed

Changed

7.31.1 - 2022.08.26

Fixed

7.31.0 - 2022.08.24

Added

Fixed

Changed

7.30.1 - 2022.06.23

Fixed

Changed

7.30.0 - 2022.05.18

Added

Fixed

Changed

  • [readme] remove global usage and eslint version from readme (#3254 @aladdin-add)
  • [Refactor] fix linter errors (#3261 @golopot)
  • [Docs] no-unused-prop-types: fix syntax errors (#3259 @mrdulin)
  • [Refactor] improve performance for detecting function components (#3265 @golopot)
  • [Refactor] improve performance for detecting class components (#3267 @golopot)
  • [Refactor] no-deprecated: improve performance (#3271 @golopot)
  • [Refactor] no-did-mount-set-state, no-did-update-set-state, no-will-update-set-state: improve performance (#3272 @golopot)
  • [Refactor] improve performance by avoiding unnecessary Components.detect (#3273 @golopot)
  • [Refactor] add isParenthesized AST util (#3203 @Belco90)
  • [Docs] default-props-match-prop-types, require-default-props, sort-prop-types: fix typos (#3279 @nix6839)
  • [Refactor] improve performance of rule merging (#3281 @golopot)
  • [Refactor] improve performance of component detection (#3276 @golopot)

7.29.4 - 2022.03.13

Fixed

7.29.3 - 2022.03.03

Fixed

7.29.2 - 2022.02.25

Fixed

7.29.1 - 2022.02.25

Fixed

  • jsx-key: prevent false "missing array key" warning (#3215 @ljharb)
  • jsx-indent: avoid checking returns sans jsx (#3218 @ljharb)
  • jsx-key: avoid a crash (#3220 @ljharb)
  • version settings: avoid a crash with an invalid version (#3219 @ljharb)

7.29.0 - 2022.02.24

Added

Fixed

Changed

7.28.0 - 2021.12.22

Added

Fixed

Changed

7.27.1 - 2021.11.18

Fixed

Changed

  • [readme] fix syntax typo (#3141 @moselhy)

7.27.0 - 2021.11.09

Added

Fixed

Changed

7.26.1 - 2021.09.29

Fixed

Changed

7.26.0 - 2021.09.20

Added

Fixed

Changed

7.25.3 - 2021.09.19

Fixed

  • prop-types, propTypes: bail out unknown generic types inside func params (#3076 @vedadeepta)

Changed

  • [readme] Update broken link for configuration files (#3071 @prateek3255)
  • [Refactor] create/extract isCreateElement and isDestructuredFromPragmaImport utils (@ljharb)

7.25.2 - 2021.09.16

Fixed

  • [jsx-no-useless-fragments]: Handle insignificant whitespace correctly when allowExpressions is true (#3061 @benj-dobs)
  • prop-types, propTypes: handle implicit children prop in react's generic types (#3064 @vedadeepta)
  • display-name: fix arrow function returning result of function call with JSX arguments being interpreted as component (#3065 @danielfinke)
  • jsx-no-target-blank: avoid crash on attr-only href (#3066 @ljharb @gaz77a)
  • jsx-uses-vars: ignore lowercase tag names (#3070 @alanorozco)

7.25.1 - 2021.08.29

Fixed

7.25.0 - 2021.08.27

Added

Fixed

Changed

7.24.0 - 2021.05.27

Added

  • component detection: add componentWrapperFunctions setting (#2713 @@jzabala @LandonSchropp)
  • no-unused-prop-types: add ignore option (#2972 @grit96)
  • version detection: support recursive processor virtual filename (#2965 @JounQin)

Fixed

Changed

7.23.2 - 2021.04.08

Fixed

Changed

  • Fix CHANGELOG.md (#2950 @JounQin)

7.23.1 - 2021.03.23

Fixed

  • version detection: support processor virtual filename (#2949 @JounQin)

7.23.0 - 2021.03.22

Added

Fixed

Changed

7.22.0 - 2020.12.29

Added

Fixed

Docs

7.21.5 - 2020.10.19

Fixed

Changed

  • [Tests] jsx-indent-props: Add passing test (#2823 @Hypnosphi)

7.21.4 - 2020.10.09

Fixed

7.21.3 - 2020.10.02

Fixed

  • prop-types: fix Cannot read property 'type' of undefined error when destructured param (#2807 @minwe)
  • no-typos: avoid crash on spread syntax in createReactClass object (#2816 @ljharb @Songyu-Wang)

7.21.2 - 2020.09.24

Fixed

7.21.1 - 2020.09.23

Fixed

7.21.0 - 2020.09.22

Added

Fixed

Changed

7.20.6 - 2020.08.12

Fixed

Changed

7.20.5 - 2020.07.28

Fixed

Docs

7.20.4 - 2020.07.26

Fixed

  • improve algorithm to check if a variable is coming from the pragma ([#2706][] @jzabala)
  • prop-types: handle component returning null (#2696 @hank121314)
  • prop-types/function-component-definition: Add check for first letter capitalization in functional component detection (#2699 @jzabala)
  • prop-types: use variable value in prop type fields defined by variables (#2704 @jzabala)
  • no-typos: warn on a bindingless react import

Changed

  • [Tests] boolean-prop-naming: Added test for function invocation of bool (#2697 @ajkovar)
  • [Tests] jsx-curly-brace-presence, jsx-no-comment-textnodes: add passing tests
  • [Refactor] no-unused-state: avoid a loop

7.20.3 - 2020-06-30

Fixed

7.20.2 - 2020-06-29

Fixed

7.20.1 - 2020-06-28

Fixed

Changed

  • forbid-prop-types: warn on destructured values as well (#2676 @ajkovar)
  • relax JSX pragma regexp (#2643 @gfmio)
  • Cache detected React version (#2673 @lencioni)
  • [refactor] jsx-pascal-case: Remove xregexp (#2636 @yacinehmito))
  • [Tests] a no-typos test fails in eslint v7.3 ([#2678][] @toshi-toma)
  • [Deps] update jsx-ast-utils, object.entries, resolve
  • [Dev Deps] update @types/eslint, @types/estree, @types/node, @typescript-eslint/parser, eslint-config-airbnb-base, eslint-plugin-eslint-plugin, eslint-plugin-import, typescript

7.20.0 - 2020-05-12

Added

Fixed

Docs

Changed

  • [Deps] Move "semver" to devDependencies (#2595 @rajivshah3)
  • [eslint] remove operator-linebreak override (#2578 @golopot)
  • [Tests] button-has-type: ensure no mistakenly allowed identifiers named button/submit/reset (#2625 @golopot)
  • [Tests] displayName: add a test case (#2593 @golopot)
  • [Dev Deps] update @types/eslint, @types/estree, @types/node, @typescript-eslint/parser, coveralls, eslint-config-airbnb-base, eslint-plugin-import, typescript

7.19.0 - 2020-03-06

Added

Fixed

Changed

7.18.3 - 2020-02-02

Fixed

7.18.2 - 2020-02-01

Fixed

7.18.1 - 2020-02-01

Fixed

Changed

  • [Docs] use markdown-magic to automatically sort all rules alphabetically (#1742 @ybiquitous)
  • [Docs] jsx-props-no-spreading: fix typo to use correct rule (#2547 @jonggyun))

7.18.0 - 2020-01-15

Added

Fixed

Changed

  • [Docs] no-render-return-value: Fix title (#2540 @micnic)
  • [Refactor]: remove unused codes in util/propTypes (#2288 @golopot)
  • no-typos: check static lifecycle methods (#2006 @bsonntag)
  • [Docs] jsx-first-prop-new-line: Fix rule name in "Rule Options" section (#2535 @barreira)
  • [Tests] no-unused-prop-types: Added test cases (#977 @dozoisch)
  • [Tests] avoid running tests on pretest job
  • [meta] Move eslint-plugin-eslint-plugin to devDeps (#2510 @nstepien)
  • [Deps] update array-includes, object.entries, object.fromentries, object.values, resolve

7.17.0 - 2019-11-28

Added

Fixed

Changed

7.16.0 - 2019-10-04

Added

Fixed

7.15.1 - 2019-10-01

Fixed

Changed

7.15.0 - 2019-09-30

Added

Fixed

Changed

7.14.3 - 2019-07-23

Fixed

  • Fix prop-types to ignore validation when Flow indexers are used (#2330 @yannickcr)
  • Fix error being thrown after the first warning when react version cannot be detected (#2336 @abhishekdev)
  • Fix component detection when memo and forwardRef are used together (#2349 @yannickcr)

Changed

  • Documentation improvements (@ljharb, #2354 @golopot)

7.14.2 - 2019-06-24

Fixed

7.14.1 - 2019-06-24

Fixed

7.14.0 - 2019-06-23

Added

Fixed

Changed

7.13.0 - 2019-05-03

Added

Fixed

Changed

7.12.4 - 2019-01-16

Fixed

Changed

7.12.3 - 2019-01-04

Fixed

Changed

  • [Docs] add a missing comma in the JSON settings (#2117, @haideralsh)
  • [Docs] update README to document React version detection (#2114, @mohsinulhaq)

7.12.2 - 2019-01-02

Fixed

  • prop-types: avoid crash on used prevProps (#2095, @ljharb)
  • Version warning: Link does not end with '.' (#2103, @yoyo837))
  • forbid-prop-types: fix crash with propWrapper check on MemberExpressions (#2104, @ljharb)

7.12.1 - 2019-01-01

Fixed

Changed

  • Fix CHANGELOG.md (#2097, @alexzherdev)

7.12.0 - 2018-12-27

Added

  • no-typos: Support createClass (#1828, @alexzherdev)
  • Support detecting React.forwardRef/React.memo (#2089, @jomasti)
  • jsx-indent: add checkAttributes option for JSX attribute indentation (#2086, @jomasti)
  • Change allowed propWrapperFunctions setting values (#2065, @jomasti)
  • add jsx-fragments rule to enforce fragment syntax (#1994, @alexzherdev)
  • Support "detect" option for React version setting (#1978, @alexzherdev)
  • Support shorthand fragment syntax in many rules (#1956, @alexzherdev)
  • jsx-no-literals: print node value in warning message (#2008, @jlgonzalezdev)

Fixed

Changed

7.11.1 - 2018-08-14

Fixed

  • stop crashing when assigning to propTypes (#1932, @alexzherdev)

Changed

  • Fix changelog links (#1926, @ferhatelmas)
  • Fix changelog links (#1929, @alexzherdev)

7.11.0 - 2018-08-13

Added

Fixed

Changed

7.10.0 - 2018-06-24

Added

Fixed

Changed

7.9.1 - 2018-06-03

  • Nothing was fixed; this is a republish with some updated deps. (#1804 @ljharb)

7.9.0 - 2018-06-03

Added

Fixed

  • Fix static lifecycle methods validation in sort-comp (#1793 @lynxtaa)
  • Fix crash in no-typos when encountering anonymous react imports (#1796 @jsg2021)
  • Fix ESLint 3 support (#1779)

Changed

  • Documentation improvements (#1794 @lencioni)
  • Update Travis CI configuration to test on multiple ESLint verions

7.8.2 - 2018-05-13

Fixed

7.8.1 - 2018-05-12

Fixed

7.8.0 - 2018-05-11

Added

Fixed

Changed

  • Documentation improvements (#1699 @ronanmathew, #1743 @ybiquitous, #1753 @awthwathje, #1783 @chentsulin, #1703 @ferhatelmas)

7.7.0 - 2018-02-19

Added

Fixed

Changed

7.6.1 - 2018-01-28

Fixed

7.6.0 - 2018-01-25

Added

Fixed

Changed

7.5.1 - 2017-11-19

Fixed

Changed

  • Documentation improvements (#1546 @jseminck)

7.5.0 - 2017-11-18

Added

Fixed

Changed

7.4.0 - 2017-09-24

Added

Fixed

Changed

  • Documentation improvements (#1392 @xcatliu, #1403 @piperchester, #1432 @jneuendorf)

7.3.0 - 2017-08-21

Added

  • Add checks for propTypes, contextTypes and childContextTypes to no-typos (#213 @DianaSuvorova)

Fixed

Changed

  • Documentation improvements (#1383 @mjomble)

7.2.1 - 2017-08-14

Fixed

Changed

  • Documentation improvements (#1123 @penx)

7.2.0 - 2017-08-09

Added

Fixed

Changed

  • Documentation improvements (#1261 @mminer, #1005 @yooungt13, #1289 @konekoya, #1308 @xcatliu, #1306 @egberts, #1329 #1344 @DianaSuvorova)
  • ES6-ify codebase (#1274 #1277 #1281 @dfilipidisz)
  • Code refactoring (@ljharb)
  • Update Travis CI and AppVeyor CI configurations (@lencioni)

7.1.0 - 2017-06-13

Added

Fixed

Changed

  • Set ESLint 4.0.0 as valid peerDependency
  • Dead code removal (#1227 @jseminck)
  • Update dependencies (@ljharb)
  • Documentation improvements (#1071 @adnasa, #1199 @preco21, #1222 @alexilyaev, #1231 @vonovak, #1239 @webOS101, #1241 @102)

7.0.1 - 2017-05-13

Fixed

Changed

  • Update dependencies
  • Documentation improvements (#1173 @luftywiranda13, #1192 @markus-willems)

7.0.0 - 2017-05-06

Added

Breaking

Fixed

Changed

6.10.3 - 2017-03-20

Fixed

6.10.2 - 2017-03-19

Fixed

6.10.1 - 2017-03-19

Fixed

6.10.0 - 2017-02-16

Added

Fixed

Changed

  • Tests improvements (@ljharb)
  • Documentation improvements (#958 @Jorundur, #1010 @amilajack, #1041 @EvNaverniouk, #1050 @lencioni, #1062 @dguo)

6.9.0 - 2017-01-08

Added

Fixed

  • Fix Node.js 0.10 support (#1000 @ljharb)
  • Fix prop-types to correctly assign props to components (#991)

Changed

  • Documentation improvements (#995 @rutsky)

6.8.0 - 2016-12-05

Added

Fixed

  • Fix jsx-indent with multiline jsx in ternaries (#966)
  • Fix component detection to ignore async functions (#989 @taion)
  • Fix jsx-curly-spacing autofix to not delete comments (#648)
  • Fix auto-enabling of eslint-plugin-react in exported configurations (#984 @jamischarles)

Changed

  • Update dependencies
  • Documentation improvements (#960 @evilebottnawi, #973 @JamesWatling, #982 @captbaritone)

6.7.1 - 2016-11-15

Fixed

6.7.0 - 2016-11-14

Added

Fixed

Changed

6.6.0 - 2016-11-06

Added

Fixed

Changed

  • Documentation improvements (#941 @pwmckenna)

6.5.0 - 2016-11-01

Added

Fixed

Changed

  • Update dependencies
  • Add deprecated metadata to deprecated rules (#911 @randycoulman)
  • Auto-enable eslint-plugin-react in exported configurations (#925 @MoOx)
  • Documentation improvements (#910 @Wilfred, #932 @gnarf)

6.4.1 - 2016-10-10

Fixed

6.4.0 - 2016-10-09

Added

Fixed

Changed

  • Update dependencies
  • Documentation improvements (#860 @fson, #863 @corydolphin, #830 @eelyafi, #876 @manovotny, #877 @gaearon)

6.3.0 - 2016-09-20

Added

Fixed

6.2.2 - 2016-09-15

Fixed

6.2.1 - 2016-09-13

Fixed

Changed

  • Update dependencies
  • Documentation improvements (@ljharb, #794 @dougshamoo, #813 @AndiDog, #815 @chris-vaszauskas)

6.2.0 - 2016-08-28

Added

Fixed

Changed

  • Update dependencies
  • Documentation improvements (@lencioni)

6.1.2 - 2016-08-17

Fixed

Changed

  • Documentation improvements

6.1.1 - 2016-08-16

Fixed

Changed

  • Documentation improvements (#769 @daltones)

6.1.0 - 2016-08-14

Added

Fixed

Changed

  • Update dependencies
  • Documentation improvements (#759 @embrown, #703 #753 @lencioni, #739 @ljharb, #731 @wKich, #745 @petersendidit, #659 @dguo)

6.0.0 - 2016-08-01

Added

Breaking

Fixed

Changed

  • Only report jsx-filename-extension warning once per file (#660 @mathieumg)
  • Update SVG and DOM attribute list for no-unknown-property
  • Update rules to use the new ESLint rule format (#661 @petersendidit)
  • Update dependencies
  • Documentation improvements (#724 @lencioni)
  • Update Travis CI and AppVeyor CI configurations (@ljharb)

5.2.2 - 2016-06-17

Fixed

5.2.1 - 2016-06-17

Fixed

5.2.0 - 2016-06-17

Added

Fixed

Changed

5.1.1 - 2016-05-10

Fixed

5.1.0 - 2016-05-10

Added

Fixed

Changed

  • Update dependencies
  • Documentation improvements (@coryhouse, #581 @scurker, #588)

5.0.1 - 2016-04-18

Fixed

5.0.0 - 2016-04-17

Added

Breaking

  • Update rules for React 15:
    • Add warnings for LinkedStateMixin, ReactPerf.printDOM and ReactPerf.getMeasurementsSummaryMap in no-deprecated
    • Allow stateless components to return null in prefer-stateless-function
    • Remove SVG attributes warnings (#490)

If you're still not using React 15 you can keep the old behavior by setting the React version to 0.14 in the shared settings.

Fixed

Changed

  • Update dependencies
  • Documentation improvements

4.3.0 - 2016-04-07

Added

Fixed

Changed

  • Update dependencies
  • Documentation improvements (#509 @coryhouse, #526 @ahoym)

4.2.3 - 2016-03-15

Fixed

4.2.2 - 2016-03-14

Fixed

Changed

  • Update dependencies
  • Add shared setting for React version

4.2.1 - 2016-03-08

Fixed

  • Fix sort-prop-types crash with spread operator (#478)
  • Fix stateless components detection when conditionally returning JSX (#486)
  • Fix case where props were not assigned to the right component (#485)
  • Fix missing getChildContext lifecycle method in prefer-stateless-function (#492)

4.2.0 - 2016-03-05

Added

Fixed

  • Fix jsx-no-undef crash on objects (#469)
  • Fix propTypes detection when declared before the component (#472)

Changed

  • Update dependencies
  • Documentation improvements (#464 @alex-tan, #466 @awong-dev, #470 @Gpx; #462 @thaggie)

4.1.0 - 2016-02-23

Added

  • Add component detection for class expressions
  • Add displayName detection for class expressions in display-name (#419)

Fixed

  • Fix used props detection in components for which we are not confident in prop-types (#420)
  • Fix false positive in jsx-key (#456 @jkimbo)

Changed

  • Documentation improvements (#457 @wyze)

4.0.0 - 2016-02-19

Added

Breaking

  • Add support for static methods to sort-comp. Static methods must now be declared first, see rule documentation (#128 @lencioni)
  • Add shareable config in place of default configuration. jsx-uses-vars is not enabled by default anymore, see documentation (#192)
  • Rename jsx-sort-prop-types to sort-prop-types. jsx-sort-prop-types still works but will trigger a warning (#87 @lencioni)
  • Remove deprecated jsx-quotes rule (#433 @lencioni)
  • display-name now accept the transpiler name by default. You can use the ignoreTranspilerName option to get the old behavior, see rule documentation (#440 @lencioni)

Fixed

Changed

  • Update dependencies (#426 @quentin-)
  • Documentation improvements (#414 @vkrol, #370 @tmcw, #441 #429 @lencioni, #432 @note89, #438 @jmann6)

3.16.1 - 2016-01-24

Fixed

3.16.0 - 2016-01-24

Added

Fixed

Changed

  • Update dependencies

3.15.0 - 2016-01-12

Added

Fixed

  • Fix prop-types crash when initializing class variable with an empty object (#383)
  • Fix prop-types crash when propTypes are using the spread operator (#389)

Changed

  • Improve sort-comp error messages (#372 @SystemParadox)
  • Update dependencies

3.14.0 - 2016-01-05

Added

  • Add jsx-indent rule (#342)
  • Add shared setting for pragma configuration (#228 @NickStefan)

Fixed

Changed

  • Add AppVeyor CI to run tests on a Windows platform
  • Add sort-comp codemod to sort-comp documentation (#381 @turadg)

3.13.1 - 2015-12-26

Fixed

3.13.0 - 2015-12-24

Added

Fixed

Changed

  • Documentation improvements (#368 @lencioni, #370 @tmcw, #371)
  • Update dependencies

3.12.0 - 2015-12-20

Added

Fixed

Changed

3.11.3 - 2015-12-05

Fixed

Changed

3.11.2 - 2015-12-01

Fixed

Changed

3.11.1 - 2015-11-29

Fixed

3.11.0 - 2015-11-29

Added

Fixed

  • Fix destructured props detection in stateless components (#326)
  • Fix props validation for nested stateless components (#331)
  • Fix require-extension to ignore extension if it's part of the package name (#319)

Changed

3.10.0 - 2015-11-21

Added

Fixed

  • Fix crash on incomplete class property declaration (#317 @dapetcu21)
  • Fix crash with ESLint 1.10.0 (#323 @lukekarrys)

3.9.0 - 2015-11-17

Added

Fixed

  • Fix crash when destructuring with only the rest spread (#269)
  • Fix variables detection when searching for related components (#303)
  • Fix no-unknown-property to not check custom elements (#308 @zertosh)

Changed

3.8.0 - 2015-11-07

Added

Fixed

  • Fix classes with properties to always be marked as components (#291)
  • Fix ES5 class detection when using createClass by itself (#297)
  • Fix direct props detection (#298)
  • Ignore functions containing the keyword this during component detection

3.7.1 - 2015-11-05

Fixed

  • Fix sort-comp crash on stateless components (#285)
  • Fix crash in ES5 components detection (#286)
  • Fix ES5 components detection from nested functions (#287)

3.7.0 - 2015-11-05

Added

Fixed

  • Fix a lot of issues about components detection, mostly related to stateless components (#264, #267, #268, #276, #277, #280)

Changed

  • Update dependencies

3.6.3 - 2015-10-20

Fixed

3.6.2 - 2015-10-18

Fixed

  • Fix wrong prop-types detection (#255)

3.6.1 - 2015-10-18

Fixed

  • Fix props validation in constructor (#254)

3.6.0 - 2015-10-18

Added

Fixed

Changed

  • Update dependencies
  • Improve components detection (#233)
  • Documentation improvements (#248 @dguo)

3.5.1 - 2015-10-01

Fixed

Changed

  • Documentation improvements (#232 @edge)

3.5.0 - 2015-09-28

Added

Fixed

  • Fix no-did-mount/update-set-state rules, these rules were not working on ES6 classes

Changed

  • Update dependencies
  • Documentation improvements (#222 @Andersos)

3.4.2 - 2015-09-18

Fixed

  • Only display the jsx-quotes deprecation warning with the default formatter (#221)

3.4.1 - 2015-09-17

Fixed

  • Fix jsx-quotes rule deprecation message (#220)

3.4.0 - 2015-09-16

Added

Deprecated

  • Deprecate jsx-quotes rule, will now trigger a warning if used (#217)

3.3.2 - 2015-09-10

Changed

  • Add state in lifecycle methods for sort-comp rule (#197 @mathieudutour)
  • Treat component with render which returns createElement as valid (#206 @epmatsw)

Fixed

3.3.1 - 2015-09-01

Changed

  • Update dependencies
  • Update changelog to follow the Keep a CHANGELOG standards
  • Documentation improvements (#198 @lencioni)

Fixed

3.3.0 - 2015-08-26

Added

Changed

  • Update dependencies

Fixed

  • Fix crash on propTypes declarations with an empty body (#193 @mattyod)

3.2.3 - 2015-08-16

Changed

  • Update dependencies

Fixed

  • Fix object rest/spread handling (#187 @xjamundx, #189 @Morantron)

3.2.2 - 2015-08-11

Changed

  • Remove peerDependencies (#178)

3.2.1 - 2015-08-08

Fixed

  • Fix crash when propTypes don't have any parent (#182)
  • Fix jsx-no-literals reporting errors outside JSX (#183 @CalebMorris)

3.2.0 - 2015-08-04

Added

Changed

  • Update dependencies

Fixed

3.1.0 - 2015-07-28

Added

Changed

  • Update dependencies
  • Documentation improvements (#167 @ngbrown)

Fixed

3.0.0 - 2015-07-21

Added

Breaking

  • In jsx-curly-spacing braces spanning multiple lines are now allowed with never option (#156 @mathieumg)

Fixed

  • Fix multiple var and destructuring handling in prop-types (#159)
  • Fix crash when retrieving propType name (#163)

2.7.1 - 2015-07-16

Changed

  • Update peerDependencies requirements (#154)
  • Update codebase for ESLint v1.0.0
  • Change oneOfType to actually keep the child types (#148 @CalebMorris)
  • Documentation improvements (#147 @lencioni)

2.7.0 - 2015-07-11

Added

Fixed

  • Fix properties limitations on propTypes (#139)
  • Fix component detection (#144)

2.6.4 - 2015-07-02

Fixed

  • Fix simple destructuring handling (#137)

2.6.3 - 2015-06-30

Fixed

2.6.2 - 2015-06-28

Fixed

  • Fix props validation when using a prop as an object key (#132)

2.6.1 - 2015-06-28

Fixed

  • Fix crash in prop-types when encountering an empty variable declaration (#130)

2.6.0 - 2015-06-28

Added

  • Add support for nested propTypes (#62 #105 @Cellule)
  • Add require-extension rule (#117 @scothis)
  • Add support for computed string format in prop-types (#127 @Cellule)
  • Add ES6 methods to sort-comp default configuration (#97 #122)
  • Add support for props destructuring directly on the this keyword
  • Add acceptTranspilerName option to display-name rule (#75)
  • Add schema to validate rules options

Changed

  • Update dependencies

Fixed

  • Fix test command for Windows (#114 @Cellule)
  • Fix detection of missing displayName and propTypes when ecmaFeatures.jsx is false (#119 @rpl)
  • Fix propTypes destructuring with properties as string (#118 @Cellule)
  • Fix jsx-sort-prop-types support for keys as string (#123 @Cellule)
  • Fix crash if a ClassProperty has only one token (#125)
  • Fix invalid class property handling in jsx-sort-prop-types (#129)

2.5.2 - 2015-06-14

Fixed

2.5.1 - 2015-06-14

Changed

  • Update dependencies
  • Documentation improvements (#99 @morenoh149)

Fixed

2.5.0 - 2015-06-04

Added

Changed

  • Update dependencies
  • Documentation improvements (#92 #93 @lencioni)

2.4.0 - 2015-05-30

Added

Changed

  • Update dependencies
  • Documentation improvement (#91 @matthewwithanm)

Fixed

2.3.0 - 2015-05-14

Added

Changed

  • Update dependencies
  • Improve errors locations for prop-types

Fixed

  • Fix quoted propTypes in ES6 (#77)

2.2.0 - 2015-04-22

Added

Changed

  • Documentation improvements (#71 @AlexKVal)

Fixed

  • Fix variables marked as used when a prop has the same name (#69 @burnnat)

2.1.1 - 2015-04-17

Added

  • Add support for classes static properties (#43)
  • Add tests for the babel-eslint parser
  • Add ESLint as peerDependency (#63 @AlexKVal)

Changed

  • Documentation improvements (#55 @AlexKVal, #60 @chriscalo)

2.1.0 - 2015-04-06

Added

Changed

Fixed

  • Fix describing comment for hasSpreadOperator() method (#53 @AlexKVal)

2.0.2 - 2015-03-31

Fixed

2.0.1 - 2015-03-30

Fixed

  • Fix props detection when used in an object (#41)

2.0.0 - 2015-03-29

Added

Changed

  • Update dependencies

Breaking

  • In prop-types the children prop is no longer ignored

Fixed

  • Fix components are now detected when using ES6 classes (#24)
  • Fix prop-types now return the right line/column (#33)
  • Fix props are now detected when destructuring (#27)
  • Fix only check for computed property names in prop-types (#36 @burnnat)

1.6.1 - 2015-03-25

Changed

  • Update jsx-quotes documentation

Fixed

1.6.0 - 2015-03-22

Added

Changed

  • Allow this.getState references (not calls) in lifecycle methods (#22 @benmosher)
  • Update dependencies

Fixed

1.5.0 - 2015-03-14

Added

Fixed

1.4.1 - 2015-03-03

Fixed

  • Fix this.props.children marked as missing in props validation (#7)
  • Fix usage of this.props without property (#8)

1.4.0 - 2015-02-24

Added

Changed

  • Update prop-types to check props usage insead of propTypes presence (#4)

1.3.0 - 2015-02-24

Added

Changed

  • Update dependencies

1.2.2 - 2015-02-09

Changed

  • Update dependencies

Fixed

1.2.1 - 2015-01-29

Changed

1.2.0 - 2014-12-29

Added

Fixed

1.1.0 - 2014-12-28

Added

1.0.0 - 2014-12-16

Added

  • First revision