From 2fe9dfa89c5222da6bf28c21ef86cf7fb5c9a4f3 Mon Sep 17 00:00:00 2001 From: camchenry <1514176+camchenry@users.noreply.github.com> Date: Fri, 17 Oct 2025 10:26:43 +0000 Subject: [PATCH] perf(linter): update `prefer-node-protocol` to use diverging match (#14699) Diverging match is recognized by the linter codegen, so adding the `return` here enables node type analysis. --- crates/oxc_linter/src/generated/rule_runner_impls.rs | 8 +++++++- .../oxc_linter/src/rules/unicorn/prefer_node_protocol.rs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/oxc_linter/src/generated/rule_runner_impls.rs b/crates/oxc_linter/src/generated/rule_runner_impls.rs index a02fa73e6ee76..08db8c5d02469 100644 --- a/crates/oxc_linter/src/generated/rule_runner_impls.rs +++ b/crates/oxc_linter/src/generated/rule_runner_impls.rs @@ -3541,7 +3541,13 @@ impl RuleRunner for crate::rules::unicorn::prefer_negative_index::PreferNegative } impl RuleRunner for crate::rules::unicorn::prefer_node_protocol::PreferNodeProtocol { - const NODE_TYPES: Option<&AstTypesBitset> = None; + const NODE_TYPES: Option<&AstTypesBitset> = Some(&AstTypesBitset::from_types(&[ + AstType::CallExpression, + AstType::ExportNamedDeclaration, + AstType::ImportDeclaration, + AstType::ImportExpression, + AstType::TSImportEqualsDeclaration, + ])); const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run; } diff --git a/crates/oxc_linter/src/rules/unicorn/prefer_node_protocol.rs b/crates/oxc_linter/src/rules/unicorn/prefer_node_protocol.rs index 45a2cd479582d..d430f9a64679d 100644 --- a/crates/oxc_linter/src/rules/unicorn/prefer_node_protocol.rs +++ b/crates/oxc_linter/src/rules/unicorn/prefer_node_protocol.rs @@ -64,7 +64,7 @@ impl Rule for PreferNodeProtocol { AstKind::ExportNamedDeclaration(export) => { export.source.as_ref().map(|item| (item.value, item.span)) } - _ => None, + _ => return, }; let Some((string_lit_value, span)) = string_lit_value_with_span else { return;