ESLint with React gives `no-unused-vars` errors
First, install the following module npm install --save-dev eslint-plugin-react
.
Then, in your .eslintrc.json
, under extends
, include the following plugin:
'extends': [
'plugin:react/recommended'
]
Source
To solve this only problem without adding new rules from react/recommended
install eslint-plugin-react
:
npm install eslint-plugin-react --save-dev
add in .eslintrc.js
:
"plugins": ["react"]
and:
"rules": {
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error"
}