diff --git a/crates/oxc_linter/src/generated/rule_runner_impls.rs b/crates/oxc_linter/src/generated/rule_runner_impls.rs index 01ad8309edf69..a509f67dedb34 100644 --- a/crates/oxc_linter/src/generated/rule_runner_impls.rs +++ b/crates/oxc_linter/src/generated/rule_runner_impls.rs @@ -1525,7 +1525,8 @@ impl RuleRunner for crate::rules::jsdoc::require_returns_type::RequireReturnsTyp } impl RuleRunner for crate::rules::jsdoc::require_yields::RequireYields { - const NODE_TYPES: Option<&AstTypesBitset> = None; + const NODE_TYPES: Option<&AstTypesBitset> = + Some(&AstTypesBitset::from_types(&[AstType::Function, AstType::YieldExpression])); const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run; } @@ -2389,7 +2390,17 @@ impl RuleRunner } impl RuleRunner for crate::rules::typescript::array_type::ArrayType { - const NODE_TYPES: Option<&AstTypesBitset> = None; + const NODE_TYPES: Option<&AstTypesBitset> = Some(&AstTypesBitset::from_types(&[ + AstType::TSArrayType, + AstType::TSAsExpression, + AstType::TSConditionalType, + AstType::TSIndexedAccessType, + AstType::TSMappedType, + AstType::TSTypeAliasDeclaration, + AstType::TSTypeAnnotation, + AstType::TSTypeParameterInstantiation, + AstType::TSTypeReference, + ])); const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run; } diff --git a/tasks/linter_codegen/src/match_detector.rs b/tasks/linter_codegen/src/match_detector.rs index cd82f1342c67c..f7fedd2609702 100644 --- a/tasks/linter_codegen/src/match_detector.rs +++ b/tasks/linter_codegen/src/match_detector.rs @@ -17,12 +17,26 @@ impl<'a> MatchDetector<'a> { run_func: &syn::ImplItemFn, rule_runner_data: &'a RuleRunnerData, ) -> Option { - // Only consider when the body's only statement is `match node.kind() { ... }` let block = &run_func.block; - if block.stmts.len() != 1 { + // Find first match statement, skipping only simple `let = ...` statements. If there is + // anything else, especially control flow, then we return. + let first_stmt = block.stmts.iter().find(|stmt| { + // skip let statements that are not diverging + if let Stmt::Local(local) = stmt + && let Some(init) = &local.init + && init.diverge.is_none() + { + return false; + } + // Otherwise, take the first statement we find + true + })?; + // Must be the only applicable statement in the block (cannot have anything after it) + if let Some(last_stmt) = block.stmts.last() + && !std::ptr::eq(first_stmt, last_stmt) + { return None; } - let first_stmt = &block.stmts[0]; // Must be an expression statement let Stmt::Expr(expr, _) = first_stmt else { return None }; // Must be a match expression