Skip to content

Commit 5ce0a68

Browse files
authored
fix(linter/no-unused-vars): Recognize parameters used in await/yield expressions within comma expressions (#10808)
- Closes: #10806
1 parent f85bda4 commit 5ce0a68

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ fn test_vars_discarded_reads() {
236236
}
237237
foo(1)
238238
",
239+
// https://github.com/oxc-project/oxc/issues/10806
240+
"export function f1(fn: () => Promise<void>) {
241+
return async () => (await fn(), 1)
242+
}",
243+
"export function f2(fn: () => Promise<void>) {
244+
return function* () {
245+
return (yield fn(), 1);
246+
}
247+
}",
239248
];
240249

241250
let fail = vec![

crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,15 @@ impl<'a> Symbol<'_, 'a> {
607607
}
608608
}
609609
(parent, AstKind::SequenceExpression(seq)) => {
610-
if matches!(parent, AstKind::CallExpression(_)) {
610+
if matches!(
611+
parent,
612+
AstKind::CallExpression(_)
613+
| AstKind::AwaitExpression(_)
614+
| AstKind::YieldExpression(_)
615+
) {
611616
continue;
612617
}
618+
613619
debug_assert!(
614620
!seq.expressions.is_empty(),
615621
"empty SequenceExpressions should be a parse error."

0 commit comments

Comments
 (0)