Skip to content

Commit 47b09dd

Browse files
committed
perf(linter): update linter codegen to support wildcard with empty tuple
1 parent 41974d1 commit 47b09dd

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

crates/oxc_linter/src/generated/rule_runner_impls.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ impl RuleRunner for crate::rules::eslint::max_params::MaxParams {
152152
}
153153

154154
impl RuleRunner for crate::rules::eslint::new_cap::NewCap {
155-
const NODE_TYPES: Option<&AstTypesBitset> = None;
155+
const NODE_TYPES: Option<&AstTypesBitset> =
156+
Some(&AstTypesBitset::from_types(&[AstType::CallExpression, AstType::NewExpression]));
156157
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
157158
}
158159

@@ -953,7 +954,12 @@ impl RuleRunner for crate::rules::eslint::unicode_bom::UnicodeBom {
953954
}
954955

955956
impl RuleRunner for crate::rules::eslint::use_isnan::UseIsnan {
956-
const NODE_TYPES: Option<&AstTypesBitset> = None;
957+
const NODE_TYPES: Option<&AstTypesBitset> = Some(&AstTypesBitset::from_types(&[
958+
AstType::BinaryExpression,
959+
AstType::CallExpression,
960+
AstType::SwitchCase,
961+
AstType::SwitchStatement,
962+
]));
957963
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
958964
}
959965

@@ -1269,7 +1275,8 @@ impl RuleRunner for crate::rules::jest::no_test_prefixes::NoTestPrefixes {
12691275
}
12701276

12711277
impl RuleRunner for crate::rules::jest::no_test_return_statement::NoTestReturnStatement {
1272-
const NODE_TYPES: Option<&AstTypesBitset> = None;
1278+
const NODE_TYPES: Option<&AstTypesBitset> =
1279+
Some(&AstTypesBitset::from_types(&[AstType::CallExpression, AstType::Function]));
12731280
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
12741281
}
12751282

@@ -2071,7 +2078,8 @@ impl RuleRunner for crate::rules::react::exhaustive_deps::ExhaustiveDeps {
20712078
}
20722079

20732080
impl RuleRunner for crate::rules::react::forbid_elements::ForbidElements {
2074-
const NODE_TYPES: Option<&AstTypesBitset> = None;
2081+
const NODE_TYPES: Option<&AstTypesBitset> =
2082+
Some(&AstTypesBitset::from_types(&[AstType::CallExpression, AstType::JSXOpeningElement]));
20752083
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
20762084
}
20772085

@@ -2171,7 +2179,8 @@ impl RuleRunner for crate::rules::react::jsx_props_no_spread_multi::JsxPropsNoSp
21712179
}
21722180

21732181
impl RuleRunner for crate::rules::react::no_array_index_key::NoArrayIndexKey {
2174-
const NODE_TYPES: Option<&AstTypesBitset> = None;
2182+
const NODE_TYPES: Option<&AstTypesBitset> =
2183+
Some(&AstTypesBitset::from_types(&[AstType::CallExpression, AstType::JSXElement]));
21752184
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
21762185
}
21772186

@@ -2188,7 +2197,8 @@ impl RuleRunner for crate::rules::react::no_danger::NoDanger {
21882197
}
21892198

21902199
impl RuleRunner for crate::rules::react::no_danger_with_children::NoDangerWithChildren {
2191-
const NODE_TYPES: Option<&AstTypesBitset> = None;
2200+
const NODE_TYPES: Option<&AstTypesBitset> =
2201+
Some(&AstTypesBitset::from_types(&[AstType::CallExpression, AstType::JSXElement]));
21922202
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
21932203
}
21942204

tasks/linter_codegen/src/match_detector.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,19 @@ impl MatchDetector {
6565
}
6666
}
6767
Pat::Wild(_) => {
68-
// Body must be completely empty.
68+
// Body must be completely empty, or return empty type only `()`
6969
if let Expr::Block(block) = &*arm.body {
7070
if block.block.stmts.is_empty() {
7171
CollectionResult::Complete
7272
} else {
7373
CollectionResult::Incomplete
7474
}
75+
} else if let Expr::Tuple(tuple) = &*arm.body {
76+
if tuple.elems.is_empty() {
77+
CollectionResult::Complete
78+
} else {
79+
CollectionResult::Incomplete
80+
}
7581
} else {
7682
CollectionResult::Incomplete
7783
}

0 commit comments

Comments
 (0)