Skip to content

Commit 2fe9dfa

Browse files
committed
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.
1 parent 07db921 commit 2fe9dfa

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

crates/oxc_linter/src/generated/rule_runner_impls.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3541,7 +3541,13 @@ impl RuleRunner for crate::rules::unicorn::prefer_negative_index::PreferNegative
35413541
}
35423542

35433543
impl RuleRunner for crate::rules::unicorn::prefer_node_protocol::PreferNodeProtocol {
3544-
const NODE_TYPES: Option<&AstTypesBitset> = None;
3544+
const NODE_TYPES: Option<&AstTypesBitset> = Some(&AstTypesBitset::from_types(&[
3545+
AstType::CallExpression,
3546+
AstType::ExportNamedDeclaration,
3547+
AstType::ImportDeclaration,
3548+
AstType::ImportExpression,
3549+
AstType::TSImportEqualsDeclaration,
3550+
]));
35453551
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
35463552
}
35473553

crates/oxc_linter/src/rules/unicorn/prefer_node_protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Rule for PreferNodeProtocol {
6464
AstKind::ExportNamedDeclaration(export) => {
6565
export.source.as_ref().map(|item| (item.value, item.span))
6666
}
67-
_ => None,
67+
_ => return,
6868
};
6969
let Some((string_lit_value, span)) = string_lit_value_with_span else {
7070
return;

0 commit comments

Comments
 (0)