Getting unused vars error when the variable is used in JSX
See original GitHub issueGetting following error, 9:8 error “favicon” is defined but never used no-unused-vars
when my React’s render method code is,
render() {
const favicon = require('../../../favicon.ico');
return (
<html>
<head>
<meta charSet="utf-8" />
<link rel="shortcut icon" href={favicon} type="image/x-icon" />
Issue Analytics
- State:
- Created 8 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
ESLint with React gives `no-unused-vars` errors
Use eslint-plugin-react to ignore React variables. ... show the error and it is pretty straightforward to ignore the unused variable error.
Read more >Error for unused variable when used in JSX #459 - GitHub
I'm having trouble getting linting to work with my jsx files, it seems to think imports aren't used if they're only used in...
Read more >Turn off error for unused variables during React Development
Walkthrough on solving react error on unused variables. A quick guide on background about error message and guideline to solve it.
Read more >no-unused-vars - ESLint - Pluggable JavaScript Linter
This rule is aimed at eliminating unused variables, functions, and function parameters. A variable foo is considered to be used if any of...
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 >
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, I think I know what this is. You don’t have any rules for
eslint-plugin-react
specified in your config. Before v2 we supported default configuration for plugins (as in, plugins had ability to enable some of their own rules by default, as soon as you said you want to use that plugin). Now that functionality has been removed and replaced with embedded configs. So you need to enable one of theeslint-plugin-react
rules manually until they can create embedded config. Basically, none of your react plugin rules are enabled now. And marking react variables as used was responsibility of one of those rules (don’t remember which one).@veeracs what do you have
parser
set to in your config? Is it present? If so, just remove it. If you still get an error, please run with--debug
and share the output.