From 1986e0f08c97c1b3ccc2c7c7daf39865b22e4430 Mon Sep 17 00:00:00 2001 From: camc314 <18101008+camc314@users.noreply.github.com> Date: Sun, 12 Oct 2025 11:25:58 +0000 Subject: [PATCH] refactor(linter/no-ex-assign): use let-else chain (#14526) --- .../src/rules/eslint/no_ex_assign.rs | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_ex_assign.rs b/crates/oxc_linter/src/rules/eslint/no_ex_assign.rs index ce30f1a29f970..08ef9e162a439 100644 --- a/crates/oxc_linter/src/rules/eslint/no_ex_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_ex_assign.rs @@ -52,20 +52,22 @@ declare_oxc_lint!( impl Rule for NoExAssign { fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) { - if let AstKind::CatchParameter(catch_param) = node.kind() { - let idents = catch_param.pattern.get_binding_identifiers(); - let symbol_table = ctx.scoping(); - for ident in idents { - let symbol_id = ident.symbol_id(); - // This symbol _should_ always be considered a catch variable (since we got it from a catch param), - // but we check in debug mode just to be sure. - debug_assert!(symbol_table.symbol_flags(symbol_id).is_catch_variable()); - for reference in symbol_table.get_resolved_references(symbol_id) { - if reference.is_write() { - ctx.diagnostic(no_ex_assign_diagnostic( - ctx.semantic().reference_span(reference), - )); - } + let AstKind::CatchParameter(catch_param) = node.kind() else { + return; + }; + + let idents = catch_param.pattern.get_binding_identifiers(); + let symbol_table = ctx.scoping(); + for ident in idents { + let symbol_id = ident.symbol_id(); + // This symbol _should_ always be considered a catch variable (since we got it from a catch param), + // but we check in debug mode just to be sure. + debug_assert!(symbol_table.symbol_flags(symbol_id).is_catch_variable()); + for reference in symbol_table.get_resolved_references(symbol_id) { + if reference.is_write() { + ctx.diagnostic(no_ex_assign_diagnostic( + ctx.semantic().reference_span(reference), + )); } } }