Merge pull request #1232 from jseminck/no-unused-props-scu-2 Support lifecycle methods with nextProps/prevProps in no-unused-prop-types
Merge pull request #1232 from jseminck/no-unused-props-scu-2
Support lifecycle methods with nextProps/prevProps in no-unused-prop-types
React specific linting rules for ESLint
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.
ESLint
$ npm install eslint-plugin-react --save-dev
Add plugins section and specify ESLint-plugin-React as a plugin.
plugins
{ "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", }
displayName
key
setState
componentDidMount
componentDidUpdate
this.state
findDOMNode
isMounted
shouldComponentUpdate
React.render
ref
componentWillUpdate
React
<img />
<br />
.bind()
target='_blank'
This plugin exports a recommended configuration that enforce React good practices.
recommended
To enable this configuration use the extends property in your .eslintrc config file:
extends
.eslintrc
{ "extends": ["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.
all
eslint:all
{ "plugins": [ "react" ], "extends": ["eslint:all", "plugin:react/all"] }
Note: These configurations will import eslint-plugin-react and enable JSX in parser options.
eslint-plugin-react
ESLint-plugin-React is licensed under the MIT License.
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
ESLint-plugin-React
React specific linting rules for ESLint
Installation
Install ESLint either locally or globally.
If you installed
ESLintglobally, you have to install React plugin globally too. Otherwise, install it locally.Configuration
Add
pluginssection and specify ESLint-plugin-React as a plugin.You can also specify some settings that will be shared across all the plugin rules.
If it is not already the case you must also configure
ESLintto support JSX.With ESLint 1.x.x:
With ESLint 2.x.x or 3.x.x:
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:
List of supported rules
displayNamein a React component definitionkeypropssetStateincomponentDidMountsetStateincomponentDidUpdatethis.statefindDOMNodeisMountedshouldComponentUpdatewhen extending React.PureComponentReact.rendersetStaterefattribute.setStateincomponentWillUpdateReactwhen using JSX<img />,<br />) from receiving childrenJSX-specific rules
.bind()and arrow functions in JSX propstarget='_blank'Other useful plugins
Shareable configurations
Recommended
This plugin exports a
recommendedconfiguration that enforce React good practices.To enable this configuration use the
extendsproperty in your.eslintrcconfig file:See ESLint documentation for more information about extending configuration files.
The rules enabled in this configuration are:
All
This plugin also exports an
allconfiguration that includes every available rule. This pairs well with theeslint:allrule.Note: These configurations will import
eslint-plugin-reactand enable JSX in parser options.License
ESLint-plugin-React is licensed under the MIT License.