eslint-plugin-react 0,6,12,1,9,0,-1,3 editorconfig eslint travis-ci npm

React specific linting rules for ESLint

2 years after MIT

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

Add plugins section and specify ESLint-plugin-React as a plugin.

{
  "plugins": [
    "react"
  ]
}

You can also specify some 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
    }
  }
}

If it is not already the case you must also configure ESLint to support JSX.

With ESLint 1.x.x:

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

With ESLint 2.x.x or 3.x.x:

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

Finally, enable all of the rules that you would like to use. Use our preset to get reasonable defaults quickly, and/or choose your own:

  "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 enforce 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.

Related Repositories

eslint-plugin-immutable

eslint-plugin-immutable

ESLint plugin to disable all mutation in JavaScript. ...

eslint-plugin-import

eslint-plugin-import

ESLint plugin with rules that help validate proper imports. ...

eslint-plugin-typelint

eslint-plugin-typelint

TypeLint is an ESlint plugin for optional typing in JavaScript, based on JSDoc. ...

eslint-plugin-react-native

eslint-plugin-react-native

React Native plugin for ESLint ...

eslint-plugin-meteor

eslint-plugin-meteor

Meteor specific linting rules for ESLint ...


Top Contributors

yannickcr lencioni ljharb CalebMorris petersendidit AlexKVal zertosh Daniel15 Cellule pfhayes hamiltondanielb eelyafi benmosher evcohen EvNaverniouk glenjamin jakemmarsh jkimbo shmuga mathieumg gitim Tom910 banderson chriscalo dguo KevinGrandon rpl lukekarrys mathieudutour silvenon

Dependencies

package version
doctrine ^2.0.0
has ^1.0.1
jsx-ast-utils ^2.0.0
dev babel-eslint ^7.2.3
coveralls ^2.13.1
eslint ^4.3.0
istanbul 0.4.5
mocha ^3.5.0
peer eslint ^3.0.0 || ^4.0.0

Releases

-   v6.3.0 zip tar
-   v6.2.2 zip tar
-   v6.2.1 zip tar
-   v6.2.0 zip tar
-   v6.1.2 zip tar
-   v6.1.1 zip tar
-   v6.1.0 zip tar
-   v6.0.0 zip tar
-   v6.0.0-rc.1 zip tar
-   v6.0.0-rc.0 zip tar
-   v6.0.0-alpha.2 zip tar
-   v6.0.0-alpha.1 zip tar
-   v5.2.2 zip tar
-   v5.2.1 zip tar
-   v5.2.0 zip tar
-   v5.1.1 zip tar
-   v5.1.0 zip tar
-   v5.0.1 zip tar
-   v5.0.0 zip tar
-   v4.3.0 zip tar
-   v4.2.3 zip tar
-   v4.2.2 zip tar
-   v4.2.1 zip tar
-   v4.2.0 zip tar
-   v4.1.0 zip tar
-   v4.0.0 zip tar
-   v4.0.0-rc.1 zip tar
-   v4.0.0-rc.0 zip tar
-   v3.16.1 zip tar
-   v3.16.0 zip tar