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": [ "forbidExtraProps" ] // The names of any functions used to wrap the
                                                   // propTypes object, e.g. `forbidExtraProps`.
                                                   // If this isn't set, any propTypes wrapped in
                                                   // a function will be skipped.
  }
}

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 24
Repository Size 3.39 MB
Stars 4,744
Forks 1,221
Watchers 75
Open issues 423
Dependencies 9
Contributors 261
Tags 128
Created
Last updated
Last pushed

Top Contributors See all

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

Packages Referencing this Repo

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

Recent Tags See all

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
v7.5.1 November 19, 2017
v7.5.0 November 18, 2017
v7.4.0 September 24, 2017

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: 2018-06-25 05:57:36 UTC

Login to resync this repository