Name: eslint-plugin-react
Owner: Storybook
Description: React specific linting rules for ESLint
Forked from: yannickcr/eslint-plugin-react
Created: 2017-11-08 23:56:29.0
Updated: 2017-11-08 23:56:32.0
Pushed: 2017-11-09 22:54:00.0
Homepage: null
Size: 2576
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
React specific linting rules for ESLint
Install ESLint either locally or globally.
m install eslint --save-dev
If you installed ESLint
globally, you have to install React plugin globally too. Otherwise, install it locally.
m install eslint-plugin-react --save-dev
Add plugins
section and specify ESLint-plugin-React as a plugin.
lugins": [
"react"
You can also specify some settings that will be shared across all the plugin rules.
ettings": {
"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, such as `forbidExtraProps`. If this isn't set, any propTypes wrapped in a function will be skipped.
If it is not already the case you must also configure ESLint
to support JSX.
With ESLint 1.x.x:
cmaFeatures": {
"jsx": true
With ESLint 2.x.x or 3.x.x:
arserOptions": {
"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:
ules": {
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
displayName
in a React component definitionkey
propssetState
in componentDidMount
setState
in componentDidUpdate
this.state
findDOMNode
isMounted
shouldComponentUpdate
when extending React.PureComponentReact.render
setState
ref
attribute.setState
in componentWillUpdate
React
when using JSXshouldComponentUpdate
method<img />
, <br />
) from receiving children.bind()
and arrow functions in JSX propstarget='_blank'
This plugin exports a recommended
configuration that enforces React good practices.
To enable this configuration use the extends
property in your .eslintrc
config file:
xtends": ["eslint:recommended", "plugin:react/recommended"]
See ESLint documentation for more information about extending configuration files.
The rules enabled in this configuration are:
This plugin also exports an all
configuration that includes every available rule.
This pairs well with the eslint:all
rule.
lugins": [
"react"
xtends": ["eslint:all", "plugin:react/all"]
Note: These configurations will import eslint-plugin-react
and enable JSX in parser options.
ESLint-plugin-React is licensed under the MIT License.