React is defined but never used no-unused-vars
See original GitHub issueI have the error 'React' is defined but never used no-unused-vars
for *.jsx files with jsx markup. Here is some of my environment:
- package.json
"react": "^16.0.0"
"babel-eslint": "^8.0.1"
"eslint": "^4.8.0"
"eslint-config-airbnb": "^15.1.0" "eslint-import-resolver-webpack": "^0.8.3"
"eslint-loader": "^1.9.0"
"eslint-plugin-import": "^2.7.0"
"eslint-plugin-jsx-a11y": "^5.1.1"
"eslint-plugin-react": "^7.4.0"
- .eslintrc.json
{
"env": {
"browser": true
},
"extends": [
"airbnb",
"plugin:react/recommended"
],
"parser": "babel-eslint",
"plugins": [
"import",
"react",
"jsx-a11y"
],
"rules": {
"comma-dangle": ["error", "never"],
"max-len": ["error", 120],
"no-unused-vars": ["error", { "args": "none" }],
"react/prop-types": "off"
},
"settings": {
"import/resolver": {
"webpack": {
"config": "config/webpack/development.js"
}
}
}
}
How can I fix it?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
ESLint with React gives `no-unused-vars` errors
I have my eslintrc extending plugin:react/recommended , but it still gives me this warning. I think it's because I'm using React in a...
Read more >'React' is defined but never used no-unused-vars · Issue #11183
When i run eslint on my code, I get the error: 'React' is defined but never used no-unused-vars when I remove import 'React'...
Read more >UseState is defined but never used no-unused-vars : r/reactjs
This is a linting error. Importing stuff requires work. If you import something but never use it, resources go to waste for nothing...
Read more >no-unused-vars - ESLint - Pluggable JavaScript Linter
Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take...
Read more >eslint-plugin-no-unused-vars-rest - npm package - Snyk
An enhanced version of the ESLint core rule no-unused-vars with allowances ... eslint-plugin-react ... Error 'extra' is defined but never used. return rest;....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh, sorry, my bad ☹️ I understood what’s wrong. As I use React 0.16 I have some draft components like this:
The error is quite logical. When I change markup to
<div>Foo</div>
all works fine@ljharb I’ve just tried adding
"react/jsx-uses-vars": "error"
and"react/jsx-uses-react": "error"
rules but it didn’t work