JSPM

  • Created
  • Published
  • Downloads 23753055
  • Score
    100M100P100Q217117F
  • License MIT

React specific linting rules for ESLint

Package Exports

  • eslint-plugin-react
  • eslint-plugin-react/lib/rules/forbid-component-props
  • eslint-plugin-react/lib/rules/jsx-boolean-value
  • eslint-plugin-react/lib/rules/jsx-curly-spacing
  • eslint-plugin-react/lib/rules/jsx-equals-spacing
  • eslint-plugin-react/lib/rules/jsx-filename-extension
  • eslint-plugin-react/lib/rules/jsx-indent
  • eslint-plugin-react/lib/rules/jsx-indent-props
  • eslint-plugin-react/lib/rules/jsx-no-bind
  • eslint-plugin-react/lib/rules/jsx-no-duplicate-props
  • eslint-plugin-react/lib/rules/jsx-no-literals
  • eslint-plugin-react/lib/rules/jsx-no-target-blank
  • eslint-plugin-react/lib/rules/jsx-no-undef
  • eslint-plugin-react/lib/rules/jsx-pascal-case
  • eslint-plugin-react/lib/rules/jsx-sort-props
  • eslint-plugin-react/lib/rules/jsx-uses-react
  • eslint-plugin-react/lib/rules/jsx-uses-vars
  • eslint-plugin-react/lib/rules/no-danger
  • eslint-plugin-react/lib/rules/no-did-mount-set-state
  • eslint-plugin-react/lib/rules/no-did-update-set-state
  • eslint-plugin-react/lib/rules/no-direct-mutation-state
  • eslint-plugin-react/lib/rules/no-find-dom-node
  • eslint-plugin-react/lib/rules/no-is-mounted
  • eslint-plugin-react/lib/rules/no-set-state
  • eslint-plugin-react/lib/rules/no-string-refs
  • eslint-plugin-react/lib/rules/no-unknown-property
  • eslint-plugin-react/lib/rules/no-unused-prop-types
  • eslint-plugin-react/lib/rules/prefer-es6-class
  • eslint-plugin-react/lib/rules/prop-types
  • eslint-plugin-react/lib/rules/react-in-jsx-scope
  • eslint-plugin-react/lib/rules/require-optimization
  • eslint-plugin-react/lib/rules/self-closing-comp
  • eslint-plugin-react/lib/util/Components
  • eslint-plugin-react/lib/util/pragma
  • eslint-plugin-react/lib/util/variable
  • eslint-plugin-react/lib/util/version

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-react) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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": {
      "createClass": "createClass", // Regex for Component Factory to use, default to "createClass"
      "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

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.

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

License

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