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.

no-unused-vars highlights at wrong position

See original GitHub issue

With no-unused-vars enabled eslint highlights the last use of the variable. If it is used left and right of an assignment it should mark the one on the left.

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

Instead of this:

let x = [];
x = x.concat(x);
             ^

What did you expect to happen? It should be this:

let x = [];
x = x.concat(x);
^

What actually happened? Please copy-paste the actual, raw output from ESLint.

Steps to reproduce this issue:

  1. eslint demo

Are you willing to submit a pull request to fix this bug? No

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Apr 17, 2021

@aladdin-add we chose to highlight the last reference because that’s where the most likely error is. It’s easy to find the declaration but that last reference might not be obvious.

@snitin315 basically, you want the last write reference. You can tell by using ref.isWrite().

1reaction
aladdin-addcommented, Apr 16, 2021

@snitin315 please feel free to open a PR! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-unused-vars - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
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 >
Available rules - eslint-plugin-vue
Rule ID Description vue/multi‑word‑component‑names require component names to be always multi‑word... vue/no‑arrow‑functions‑in‑watch disallow using arrow functions to define watcher... vue/no‑computed‑properties‑in‑data disallow accessing computed properties in data...
Read more >
eslint-config-eslint | Yarn - Package Manager
... f9b70b3 Docs: Enable example highlighting in rules examples (ref #6444) (#7644) (Alex Guerrero); d50f6c1 Fix: incorrect location for no-useless-escape ...
Read more >
eslint/eslint - Gitter
Something went wrong! :( ESLint: 7.12.1 ESLint couldn't find the config ... should i expect eslint --fix to things like @typescript-eslint/no-unused-vars ?
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