React specific linting rules for ESLint
Перейти к файлу
Yannick Croissant 0efb7ad6f1 Update CHANGELOG and bump version 2016-04-06 23:08:09 +00:00
docs/rules Fix grammar in prefer-stateless-function rule 2016-04-02 15:31:09 -07:00
lib Merge pull request #508 from dthielman/pascal-edge-case 2016-04-07 00:23:04 +02:00
tests Merge pull request #508 from dthielman/pascal-edge-case 2016-04-07 00:23:04 +02:00
.editorconfig Update config files 2014-12-29 11:23:15 +01:00
.eslintignore Update config files 2014-12-29 11:23:15 +01:00
.eslintrc Update dependencies 2016-02-08 21:17:42 +00:00
.gitignore Update config files 2014-12-29 11:23:15 +01:00
.travis.yml Update node.js versions in travis config file 2015-11-17 00:24:38 +01:00
CHANGELOG.md Update CHANGELOG and bump version 2016-04-06 23:08:09 +00:00
LICENSE Initial commit 2014-12-16 00:44:14 +01:00
README.md Update docs to specify JSX closing bracket location as fixable. 2016-03-28 14:01:06 -07:00
appveyor.yml Add AppVeyor CI 2016-01-01 10:41:02 +00:00
index.js Added rule require-render-return to Library 2016-03-15 23:43:09 +02:00
package.json Update CHANGELOG and bump version 2016-04-06 23:08:09 +00:00

README.md

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

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

$ npm install eslint-plugin-react

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": {
      "pragma": "React",  // Pragma to use, default to "React"
      "version": "0.14.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:

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

Finally, enable all of the rules that you would like to use.

The plugin has a recommended configuration that enforces React good practices.

List of supported rules

JSX-specific rules

React Native rules

If you're searching for React Native specific linting rules, check out eslint-plugin-react-native.

Recommended configuration

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

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

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

See ESLint documentation for more information about extending configuration files.

The rules enabled in this configuration are:

Note: This configuration will also enable JSX in parser options.

License

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