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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -