Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,9 @@ impl<'s, 'a> Symbol<'s, 'a> {
match node.kind() {
// references used in declaration of another variable are definitely
// used by others
AstKind::VariableDeclarator(v) => {
// let a = a; is a static semantic error, even if `a` is shadowed.
debug_assert!(
v.id.kind.get_identifier().map_or_else(|| true, |id| id != name),
"While traversing {name}'s reference's parent nodes, found {name}'s declaration. This algorithm assumes that variable declarations do not appear in references."
);
AstKind::VariableDeclarator(_)
| AstKind::JSXExpressionContainer(_)
| AstKind::Argument(_) => {
// definitely used, short-circuit
return false;
}
Expand Down Expand Up @@ -382,9 +379,6 @@ impl<'s, 'a> Symbol<'s, 'a> {
| AstKind::WhileStatement(_) => {
break;
}
AstKind::JSXExpressionContainer(_) | AstKind::Argument(_) => {
return false;
}
// this is needed to handle `return () => foo++`
AstKind::ExpressionStatement(_) => {
if self.is_in_return_statement(node.id()) {
Expand Down