reactjs - React.js with ESlint settings -


when use eslint check code, got error---'react' defined never used no-unused-vars

import react 'react'; const app=({})=>{     return <div>123</div>; }; export default app; 

how modify .eslintrc.json file fix error?

use eslint-plugin-react eslint plugin introduces react specific linting rules eslint.

simply can install npm , configure in eslint config file.

npm install eslint-plugin-react --save-dev

{   "plugins": [     "react"   ] } 

and need enable react/jsx-uses-react rule in eslint config file.

"rules": {    // other rules,    "react/jsx-uses-react": 2 } 

or can enable recommended eslint-plugin-react configs extends property.

{   "extends": [... /*other presets*/, "plugin:react/recommended"] } 

however, enable additional rules enforces react practices.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -