githubEdit

eslint-plugin-react

ESLint-plugin-React

Maintenance Statusarrow-up-right NPM versionarrow-up-right Build Statusarrow-up-right Dependency Statusarrow-up-right Coverage Statusarrow-up-right Code Climatearrow-up-right Tideliftarrow-up-right

React specific linting rules for ESLint

Installation

Install ESLintarrow-up-right either locally or globally. (Note that locally, per project, is strongly preferred)

$ 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. (More about eslint shared settingsarrow-up-right)

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

Add "react" to the plugins section.

Enable JSX support.

With ESLint 2+

Enable the rules that you would like to use.

List of supported rules

JSX-specific rules

Other useful plugins

Shareable configurations

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

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

See ESLint documentationarrow-up-right 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.

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

License

ESLint-plugin-React is licensed under the MIT Licensearrow-up-right.

Last updated

Was this helpful?