-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fix(eslint-plugin): [no-unused-vars] clear error report range #8640
Changes from 2 commits
74944e5
d95260e
56ff4f2
4062305
8819bd3
00c75a4
164798e
702b828
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -419,10 +419,24 @@ export default createRule<Options, MessageIds>({ | |||||||||||||||||||||||||||||||||||||||||||||
ref.from.variableScope === unusedVar.scope.variableScope, | ||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
const node = writeReferences.length | ||||||||||||||||||||||||||||||||||||||||||||||
? writeReferences[writeReferences.length - 1].identifier | ||||||||||||||||||||||||||||||||||||||||||||||
: unusedVar.identifiers[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
const { start } = node.loc; | ||||||||||||||||||||||||||||||||||||||||||||||
const nodeVariableLength = node.name.length; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
const loc = { | ||||||||||||||||||||||||||||||||||||||||||||||
start, | ||||||||||||||||||||||||||||||||||||||||||||||
end: { | ||||||||||||||||||||||||||||||||||||||||||||||
line: start.line, | ||||||||||||||||||||||||||||||||||||||||||||||
column: start.column + nodeVariableLength, | ||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
context.report({ | ||||||||||||||||||||||||||||||||||||||||||||||
node: writeReferences.length | ||||||||||||||||||||||||||||||||||||||||||||||
? writeReferences[writeReferences.length - 1].identifier | ||||||||||||||||||||||||||||||||||||||||||||||
: unusedVar.identifiers[0], | ||||||||||||||||||||||||||||||||||||||||||||||
node, | ||||||||||||||||||||||||||||||||||||||||||||||
This comment was marked as resolved.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i delete node. thank you! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, looking closer at this... I may have led you astray, at least partially. Sorry about that! The test failures in CI are due to having removed the typescript-eslint/packages/eslint-plugin/tests/rules/no-unused-vars/no-unused-vars-eslint.test.ts Lines 56 to 77 in 584db29
Now, it's still not clear to me that the value of the My thought is Maybe @JoshuaKGoldberg or @bradzacher will know for sure? Would either of you know whether there's any reason to provide a report There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah you only need to provide one or the other. |
||||||||||||||||||||||||||||||||||||||||||||||
loc, | ||||||||||||||||||||||||||||||||||||||||||||||
messageId: 'unusedVar', | ||||||||||||||||||||||||||||||||||||||||||||||
data: unusedVar.references.some(ref => ref.isWrite()) | ||||||||||||||||||||||||||||||||||||||||||||||
? getAssignedMessageData(unusedVar) | ||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (testing) FYI - here and in other comments, there's probably no need to add new test cases; modifying existing ones to have the full |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 What do you think about changing the variable names a bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it make sense, so i change variable name. thank you!