@@ -99,36 +99,36 @@ declare_oxc_lint!(
9999
100100impl Rule for NoConditionalInTest {
101101 fn run < ' a > ( & self , node : & oxc_semantic:: AstNode < ' a > , ctx : & LintContext < ' a > ) {
102- if matches ! (
103- node. kind( ) ,
102+ match node. kind ( ) {
104103 AstKind :: IfStatement ( _)
105- | AstKind :: SwitchStatement ( _)
106- | AstKind :: ConditionalExpression ( _)
107- | AstKind :: LogicalExpression ( _)
108- ) {
109- let is_if_statement_in_test = ctx. nodes ( ) . ancestors ( node. id ( ) ) . any ( |node| {
110- let AstKind :: CallExpression ( call_expr) = node. kind ( ) else { return false } ;
111- let vitest_node = PossibleJestNode { node, original : None } ;
104+ | AstKind :: SwitchStatement ( _)
105+ | AstKind :: ConditionalExpression ( _)
106+ | AstKind :: LogicalExpression ( _) => { }
107+ _ => return ,
108+ }
109+
110+ let is_if_statement_in_test = ctx. nodes ( ) . ancestors ( node. id ( ) ) . any ( |node| {
111+ let AstKind :: CallExpression ( call_expr) = node. kind ( ) else { return false } ;
112+ let vitest_node = PossibleJestNode { node, original : None } ;
112113
113- is_type_of_jest_fn_call (
114- call_expr,
115- & vitest_node,
116- ctx,
117- & [ JestFnKind :: General ( crate :: utils:: JestGeneralFnKind :: Test ) ] ,
118- )
119- } ) ;
114+ is_type_of_jest_fn_call (
115+ call_expr,
116+ & vitest_node,
117+ ctx,
118+ & [ JestFnKind :: General ( crate :: utils:: JestGeneralFnKind :: Test ) ] ,
119+ )
120+ } ) ;
120121
121- if is_if_statement_in_test {
122- let span = match node. kind ( ) {
123- AstKind :: IfStatement ( stmt) => stmt. span ,
124- AstKind :: SwitchStatement ( stmt) => stmt. span ,
125- AstKind :: ConditionalExpression ( expr) => expr. span ,
126- AstKind :: LogicalExpression ( expr) => expr. span ,
127- _ => unreachable ! ( ) ,
128- } ;
122+ if is_if_statement_in_test {
123+ let span = match node. kind ( ) {
124+ AstKind :: IfStatement ( stmt) => stmt. span ,
125+ AstKind :: SwitchStatement ( stmt) => stmt. span ,
126+ AstKind :: ConditionalExpression ( expr) => expr. span ,
127+ AstKind :: LogicalExpression ( expr) => expr. span ,
128+ _ => unreachable ! ( ) ,
129+ } ;
129130
130- ctx. diagnostic ( no_conditional_in_test ( span) ) ;
131- }
131+ ctx. diagnostic ( no_conditional_in_test ( span) ) ;
132132 }
133133 }
134134}
0 commit comments