question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting unused vars error when the variable is used in JSX

See original GitHub issue

Getting 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:closed
  • Created 8 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ilyavolodincommented, Feb 16, 2016

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 the eslint-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).

1reaction
nzakascommented, Feb 16, 2016

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found