Skip to content

Commit 146c6f7

Browse files
committed
fix(linter/no-unused-vars): false positive with chain expression (#12609)
fixes #12592
1 parent a6ff113 commit 146c6f7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,13 @@ fn test_vars_discarded_reads() {
277277
return (yield fn(), 1);
278278
}
279279
}",
280+
// https://github.com/oxc-project/oxc/issues/12592
281+
"export const Foo = ({ onDismiss }) => {
282+
const { remove } = useToaster();
283+
return (
284+
<button onClick={() => (onDismiss?.(), remove())}>x</button>
285+
);
286+
};",
280287
];
281288

282289
let fail = vec![

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ impl<'a> Symbol<'_, 'a> {
651651
AstKind::CallExpression(_)
652652
| AstKind::AwaitExpression(_)
653653
| AstKind::YieldExpression(_)
654+
| AstKind::ChainExpression(_)
654655
) {
655656
continue;
656657
}

0 commit comments

Comments
 (0)