Skip to content

Commit

Permalink
remove regex use
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 committed Dec 11, 2024
1 parent b8877df commit 3c25fb8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/oxc_linter/src/rules/unicorn/prefer_query_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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::<Vec<_>>().join(" .")
)
}
_ => literal_value.to_string(),
};
let span = property_span.merge(&argument_expr.span());
Expand Down

0 comments on commit 3c25fb8

Please sign in to comment.