diff --git a/crates/oxc_linter/src/rules/jest/prefer_lowercase_title/mod.rs b/crates/oxc_linter/src/rules/jest/prefer_lowercase_title/mod.rs index 6c60dca87e4b8..4d5965750dd1c 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_lowercase_title/mod.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_lowercase_title/mod.rs @@ -9,7 +9,7 @@ mod tests; use crate::{ context::LintContext, rule::Rule, - utils::{parse_vitest_fn_call, JestFnKind, JestGeneralFnKind, PossibleJestNode}, + utils::{parse_jest_fn_call, JestFnKind, JestGeneralFnKind, ParsedJestFnCallNew, PossibleJestNode}, }; fn prefer_lowercase_title_diagnostic(title: &str, span: Span) -> OxcDiagnostic { @@ -194,14 +194,15 @@ impl Rule for PreferLowercaseTitle { fn run_on_jest_node<'a, 'c>( &self, - possible_vitest_node: &PossibleJestNode<'a, 'c>, + possible_jest_node: &PossibleJestNode<'a, 'c>, ctx: &'c LintContext<'a>, ) { - let node = possible_vitest_node.node; + let node = possible_jest_node.node; let AstKind::CallExpression(call_expr) = node.kind() else { return; }; - let Some(vitest_fn_call) = parse_vitest_fn_call(call_expr, possible_vitest_node, ctx) + let Some(ParsedJestFnCallNew::GeneralJest(jest_fn_call)) = + parse_jest_fn_call(call_expr, possible_jest_node, ctx) else { return; }; @@ -210,16 +211,16 @@ impl Rule for PreferLowercaseTitle { let ignores = Self::populate_ignores(&self.ignore); - if ignores.contains(&vitest_fn_call.name.as_ref()) { + if ignores.contains(&jest_fn_call.name.as_ref()) { return; } - if matches!(vitest_fn_call.kind, JestFnKind::General(JestGeneralFnKind::Describe)) { + if matches!(jest_fn_call.kind, JestFnKind::General(JestGeneralFnKind::Describe)) { if self.ignore_top_level_describe && scopes.get_flags(node.scope_id()).is_top() { return; } } else if !matches!( - vitest_fn_call.kind, + jest_fn_call.kind, JestFnKind::General(JestGeneralFnKind::Test | JestGeneralFnKind::Bench) ) { return; diff --git a/crates/oxc_linter/src/utils/vitest.rs b/crates/oxc_linter/src/utils/vitest.rs index 5d4d9b9d4ca25..bf1561001bf50 100644 --- a/crates/oxc_linter/src/utils/vitest.rs +++ b/crates/oxc_linter/src/utils/vitest.rs @@ -1,10 +1,10 @@ use oxc_ast::ast::CallExpression; use super::{ - parse_jest_fn_call, ParsedExpectFnCall, ParsedGeneralJestFnCall, ParsedJestFnCallNew, + parse_jest_fn_call, ParsedExpectFnCall, ParsedJestFnCallNew, PossibleJestNode, }; -use crate::{utils::JestFnKind, LintContext}; +use crate::LintContext; mod valid_vitest_fn; pub use crate::utils::vitest::valid_vitest_fn::VALID_VITEST_FN_CALL_CHAINS; @@ -22,19 +22,3 @@ pub fn parse_expect_and_typeof_vitest_fn_call<'a>( ParsedJestFnCallNew::GeneralJest(_) => None, } } - -pub fn parse_vitest_fn_call<'a>( - call_expr: &'a CallExpression<'a>, - possible_jest_node: &PossibleJestNode<'a, '_>, - ctx: &LintContext<'a>, -) -> Option> { - let jest_fn_call = parse_jest_fn_call(call_expr, possible_jest_node, ctx)?; - - match jest_fn_call { - ParsedJestFnCallNew::GeneralJest(jest_fn_call) => match jest_fn_call.kind { - JestFnKind::General(_) => Some(jest_fn_call), - _ => None, - }, - _ => None, - } -}