From 024b58506ee5628fbcc8866499c45ee2a0506436 Mon Sep 17 00:00:00 2001 From: camc314 <18101008+camc314@users.noreply.github.com> Date: Sat, 31 Aug 2024 20:52:04 +0000 Subject: [PATCH] refactor(linter/oxc): improve code comment for `no-accumulating-spread` (#5373) mentioned here: https://github.com/oxc-project/oxc/pull/5302#discussion_r1735759462 it's not exactly clear why we check that it's a `let` declaration kind. --- crates/oxc_linter/src/rules/oxc/no_accumulating_spread.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/oxc/no_accumulating_spread.rs b/crates/oxc_linter/src/rules/oxc/no_accumulating_spread.rs index 525e4a7831774..b2cbcdcf9a052 100644 --- a/crates/oxc_linter/src/rules/oxc/no_accumulating_spread.rs +++ b/crates/oxc_linter/src/rules/oxc/no_accumulating_spread.rs @@ -185,7 +185,8 @@ fn check_loop_usage<'a>( let AstKind::VariableDeclaration(declaration) = declaration_node.kind() else { return; }; - + // if the accumulator's declaration is not a `let`, then we know it's never + // reassigned, hence cannot be a violation of the rule if !matches!(declaration.kind, VariableDeclarationKind::Let) { return; }