Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is this reported as no-unused-vars? #12357

Closed
daningalla opened this issue Oct 1, 2019 · 10 comments
Closed

Why is this reported as no-unused-vars? #12357

daningalla opened this issue Oct 1, 2019 · 10 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion needs info Not enough information has been provided to triage this issue

Comments

@daningalla
Copy link

daningalla commented Oct 1, 2019

for(const entry of map){
     code = code.replace(entry.p, entry.r);
}

Line 90: 'entry' is defined but never used no-unused-vars

Edit:
version 1.13.0
what happened: The following warning was issued: 'Line 90: 'entry' is defined but never used no-unused-vars'
expected: since entry is used in the for loop body, I'd expect to not see that warning

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Oct 1, 2019
@g-plane g-plane added the needs info Not enough information has been provided to triage this issue label Oct 2, 2019
@eslint-deprecated
Copy link

Hi @daningalla, thanks for the issue. It looks like there's not enough information for us to know how to help you.

If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

Requesting a rule change? Please see Proposing a Rule Change for instructions.

If it's something else, please just provide as much additional information as possible. Thanks!

@platinumazure
Copy link
Member

Do you use code somewhere else, after the for-of loop?

If not, the lint message is correct- there's not much value in doing all of those replacements and reassigning to a variable you don't later use.

@daningalla
Copy link
Author

@platinumazure The message indicates the unused var is entry, which you can see is referenced in the loop body. To your question though, code is returned from the function it resides in.

@platinumazure
Copy link
Member

This is why we ask for all the information about your use case... You didn't even include the error message, so I had to guess. 😄

Please provide all the info requested in this comment. Thanks!

@daningalla
Copy link
Author

@platinumazure - gotcha, sorry. I edited the oc.

@mysticatea
Copy link
Member

Hi @daningalla. ESLint 1.13.0 doesn't exist. This is the version list: https://www.npmjs.com/package/eslint?activeTab=versions

Please fill our issue template. People have many varied environments, so we need the information that is to reproduce your case in order to investigate it. Otherwise, what we can do is very limited.

Just for information, we cannot reproduce your case on our online demo.

I remember an old issue #12117 from your code. Would you check if it's your case?

Thank you.

@kaicataldo kaicataldo removed the triage An ESLint team member will look at this issue soon label Oct 2, 2019
@daningalla
Copy link
Author

Environment (from package-lock):
node = v10.16.3
npm = 6.11.2
babel/core = 7.5.5
babel-eslint: 10.0.2
eslint: 6.4.0

Configuration
The only relevant configuration I could find is:

"eslintConfig": {
   "extends": "react-app"
 },

What parser (default, Babel-ESLint, etc.) are you using? babel-eslint

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Code in question:

    for(const entry of map){
        code = code.replace(entry.p, entry.r);
    }

Invoked using

react-scripts start

What did you expect to happen?
No warnings from eslint

What actually happened? Please include the actual, raw output from ESLint.

./src/components/shared/codeBox.jsx
Line 93:  'entry' is defined but never used  no-unused-vars

This is precisely what was going on in #12117. Also sorry if I missed other info, as you can easily tell I'm just starting in the JS space...

@kaicataldo
Copy link
Member

Have you tried the solution in that other issue? Looks like you might need to update babel-eslint.

@mysticatea
Copy link
Member

Thank you for filling the template.

Okay, you look using problematic babel-eslint 10.0.2. Please update it to 10.0.3.

@daningalla
Copy link
Author

Thank you - will close.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 1, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion needs info Not enough information has been provided to triage this issue
Projects
None yet
Development

No branches or pull requests

5 participants