From 3c25fb86d41265051092fa9dbf9c6c3512fcacfd Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Wed, 11 Dec 2024 08:37:04 +0000 Subject: [PATCH] remove regex use --- .../src/rules/unicorn/prefer_query_selector.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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());