diff --git a/crates/oxc_linter/src/rules/unicorn/prefer_query_selector.rs b/crates/oxc_linter/src/rules/unicorn/prefer_query_selector.rs index 8467f6f3d5b59..a4e356bfc8ea9 100644 --- a/crates/oxc_linter/src/rules/unicorn/prefer_query_selector.rs +++ b/crates/oxc_linter/src/rules/unicorn/prefer_query_selector.rs @@ -3,7 +3,6 @@ use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_span::{GetSpan, Span}; use phf::phf_map; -use regex::Regex; use crate::{context::LintContext, rule::Rule, utils::is_node_value_not_dom_node, AstNode}; @@ -130,10 +129,12 @@ impl Rule for PreferQuerySelector { let quotes_symbol = source_text.chars().next().unwrap(); let argument = match *cur_property_name { "getElementById" => format!("#{literal_value}"), - "getElementsByClassName" => format!( - ".{}", - Regex::new(r"\s+").unwrap().replace_all(literal_value, " .") - ), + "getElementsByClassName" => { + format!( + ".{}", + literal_value.split_whitespace().collect::>().join(" .") + ) + } _ => literal_value.to_string(), }; let span = property_span.merge(&argument_expr.span());