-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[no-unused-vars] Wrong position reported #4910
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
Comments
Could you more clearly annotate which position you expect and which position you got? Eg do this
You said you expect |
@bradzacher Sorry, I updated my comment |
@bachorp theres only 7 lines in your example. So As per my last comment (I edited after you saw it I think) could you annotate your example code with comments showing the actual and expected locations? |
@bradzacher Done |
The rule is actually right here let x = null In this code the variable let x = null
foo(x) In this code the variable let x = null
foo(x)
x = 1 // error on this line In this code you will have an error as the last line assigns a value to Putting these together: let x = null
x = foo(x)
// ^ usage of the declaration ✅
// ^ new assignment to x which is never used ❌ |
@bradzacher Can you please clarify at which position we would expect the error? If I understand your example correctly (we expect an error at ❌ but not at ✅), the rule is not right here. |
Ah - I see the bug now. |
there actually seem to be additional issues, and some of test seem to be incorrect, interface Foo {
bar: string;
baz: Foo['bar'];
// ^ reports this
} |
@armano2 - that's the same issue - we're reporting the last read instead of the last write. I don't think we ever merged this from upstream: eslint/eslint@5df5e4a Separately there are the following commits we should assess and merge in as well: |
@bradzacher correct, we do not have those changes / our rule is not reporting on them correctly, do you mind filling separate issue about this? |
I also didn't realise that this was a duplicate of #3311 oops |
Repro
Expected Result
Actual Result
Versions
@typescript-eslint/eslint-plugin
5.22.0
@typescript-eslint/parser
5.22.0
TypeScript
4.6.2
ESLint
8.14.0
node
16.12.0
The text was updated successfully, but these errors were encountered: