yannickcr/eslint-plugin-react


React specific linting rules for ESLint

License: MIT

Language: JavaScript

Keywords: development, ecmascript, eslint, javascript, lint, react


ESLint-plugin-React

Maintenance Status NPM version Build Status Build Status Dependency Status Coverage Status Code Climate

React specific linting rules for ESLint

Installation

Install ESLint either locally or globally.

$ npm install eslint --save-dev

If you installed ESLint globally, you have to install React plugin globally too. Otherwise, install it locally.

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

Configuration

Use our preset to get reasonable defaults:

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

You should also specify settings that will be shared across all the plugin rules.

{
  "settings": {
    "react": {
      "createClass": "createReactClass", // Regex for Component Factory to use,
                                         // default to "createReactClass"
      "pragma": "React",  // Pragma to use, default to "React"
      "version": "15.0", // React version, default to the latest React stable release
      "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"}
    ]
  }
}

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",
  }

List of supported rules

JSX-specific rules

Other useful plugins

Shareable configurations

Recommended

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.

The rules enabled in this configuration are:

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.

License

ESLint-plugin-React is licensed under the MIT License.

Project Statistics

Sourcerank 23
Repository Size 3.5 MB
Stars 4,846
Forks 1,243
Watchers 76
Open issues 417
Dependencies 14
Contributors 278
Tags 131
Created
Last updated
Last pushed

Top Contributors See all

Yannick Croissant Jordan Harband Joachim Seminck Joe Lencioni Jacky Ho Alex Zherdev Joshua Stiefer Patrick Hayes Sergei Startsev DianaSuvorova Mark Allen Dustin Masters David Petersen Caleb Morris Yak Jun Xiang Roy Sutton Adrian Yevgeny Petukhov Rafał Ruciński Brett Higgins

Packages Referencing this Repo

eslint-plugin-react
React specific linting rules for ESLint
Latest release 7.12.2 - Updated - 4.85K stars
@kentcdodds/eslint-plugin-react
React specific linting rules for ESLint
Latest release 6.10.0-beta.0 - Published - 4.85K stars
@zaibot/eslint-plugin-react
React specific linting rules for ESLint
Latest release 6.9.1 - Published - 4.85K stars
org.webjars.npm:eslint-plugin-react
WebJar for eslint-plugin-react
Latest release 6.2.0 - Published - 4.85K stars
eslint-plugin-react-ep
React specific linting rules for ESLint
Latest release 6.9.1 - Published - 4.85K stars
eslint-plugin-reactzaibot
React specific linting rules for ESLint
Latest release 6.9.6 - Updated - 4.85K stars
zaibot-eslint-plugin-react
React specific linting rules for ESLint
Latest release 6.9.2 - Published - 4.85K stars
eslint-plugin-react
WebJar for eslint-plugin-react
Latest release 6.2.0 - Published - 4.85K stars
eslint-plugin-react-zaibot
React specific linting rules for ESLint
Latest release 6.9.3 - Published - 4.85K stars

Recent Tags See all

v7.12.2 January 02, 2019
v7.12.1 January 01, 2019
v7.12.0 December 28, 2018
v7.11.1 August 14, 2018
v7.11.0 August 13, 2018
v7.10.0 June 25, 2018
v7.9.1 June 04, 2018
v7.9.0 June 03, 2018
v7.8.2 May 13, 2018
v7.8.1 May 11, 2018
v7.8.0 May 11, 2018
v7.8.0-rc.0 May 10, 2018
v7.7.0 February 20, 2018
v7.6.1 January 29, 2018
v7.6.0 January 25, 2018

Interesting Forks See all

infernojs/eslint-plugin-inferno
Inferno specific linting rules for ESLint
JavaScript - MIT - Last pushed - 10 stars - 6 forks
thepechinator/eslint-plugin-react
React specific linting rules for ESLint
JavaScript - MIT - Last pushed - 1 stars
Khan/eslint-plugin-react
React specific linting rules for ESLint
JavaScript - MIT - Last pushed - 1 stars
jacklovepdf/eslint-plugin-react
React specific linting rules for ESLint
JavaScript - Updated - 1 stars
niilante/eslint-plugin-react
React specific linting rules for ESLint
JavaScript - Updated - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2019-01-03 00:03:16 UTC

Login to resync this repository