Skip to content

Commit 1986e0f

Browse files
committed
refactor(linter/no-ex-assign): use let-else chain (#14526)
1 parent ce9bcf0 commit 1986e0f

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

crates/oxc_linter/src/rules/eslint/no_ex_assign.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,22 @@ declare_oxc_lint!(
5252

5353
impl Rule for NoExAssign {
5454
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
55-
if let AstKind::CatchParameter(catch_param) = node.kind() {
56-
let idents = catch_param.pattern.get_binding_identifiers();
57-
let symbol_table = ctx.scoping();
58-
for ident in idents {
59-
let symbol_id = ident.symbol_id();
60-
// This symbol _should_ always be considered a catch variable (since we got it from a catch param),
61-
// but we check in debug mode just to be sure.
62-
debug_assert!(symbol_table.symbol_flags(symbol_id).is_catch_variable());
63-
for reference in symbol_table.get_resolved_references(symbol_id) {
64-
if reference.is_write() {
65-
ctx.diagnostic(no_ex_assign_diagnostic(
66-
ctx.semantic().reference_span(reference),
67-
));
68-
}
55+
let AstKind::CatchParameter(catch_param) = node.kind() else {
56+
return;
57+
};
58+
59+
let idents = catch_param.pattern.get_binding_identifiers();
60+
let symbol_table = ctx.scoping();
61+
for ident in idents {
62+
let symbol_id = ident.symbol_id();
63+
// This symbol _should_ always be considered a catch variable (since we got it from a catch param),
64+
// but we check in debug mode just to be sure.
65+
debug_assert!(symbol_table.symbol_flags(symbol_id).is_catch_variable());
66+
for reference in symbol_table.get_resolved_references(symbol_id) {
67+
if reference.is_write() {
68+
ctx.diagnostic(no_ex_assign_diagnostic(
69+
ctx.semantic().reference_span(reference),
70+
));
6971
}
7072
}
7173
}

0 commit comments

Comments
 (0)