diff --git a/crates/biome_js_analyze/src/analyzers/nursery/use_regex_literals.rs b/crates/biome_js_analyze/src/analyzers/nursery/use_regex_literals.rs index 3b069b1f01b3..3f6b1d624ce3 100644 --- a/crates/biome_js_analyze/src/analyzers/nursery/use_regex_literals.rs +++ b/crates/biome_js_analyze/src/analyzers/nursery/use_regex_literals.rs @@ -162,7 +162,7 @@ fn create_pattern( } }; }; - let pattern = extract_literal_string(&pattern)?; + let pattern = extract_literal_string(pattern)?; let pattern = pattern.replace("\\\\", "\\"); if pattern.is_empty() || pattern == "*" || pattern == "+" || pattern == "?" { return None; @@ -197,16 +197,18 @@ fn parse_node(node: &JsNewOrCallExpression) -> Option<(AnyJsExpression, JsCallAr fn create_flags(flags: Result) -> Option { let flags = flags.ok()?; - let flags = extract_literal_string(&flags)?; + let flags = extract_literal_string(flags)?; if flags == "uv" || flags == "vu" { return None; } Some(flags) } -fn extract_literal_string(from: &AnyJsCallArgument) -> Option { - let expr = from.as_any_js_expression()?; - match expr.clone().omit_parentheses() { +fn extract_literal_string(from: AnyJsCallArgument) -> Option { + let AnyJsCallArgument::AnyJsExpression(expr) = from else { + return None; + }; + match expr.omit_parentheses() { AnyJsExpression::AnyJsLiteralExpression(expr) => { let expr = expr.as_js_string_literal_expression()?; let text = expr.inner_string_text().ok()?;