ESLint with React gives `no-unused-vars` errors ESLint with React gives `no-unused-vars` errors reactjs reactjs

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" }


Since I found this while googling, you should know that this simple rule is enough to prevent this message:

react/jsx-uses-react

The react/recommended set of rules adds many other rules you may not want.