perf(linter): use cow_utils in no_script_url (#5633)

part of #5586 

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
heygsc 2024-09-09 15:06:50 +08:00 committed by GitHub
parent 023c1607b0
commit a0370bf506
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 2 deletions

7
Cargo.lock generated
View file

@ -327,6 +327,12 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "cow-utils"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "417bef24afe1460300965a25ff4a24b8b45ad011948302ec221e8a0a81eb2c79"
[[package]]
name = "cpufeatures"
version = "0.2.12"
@ -1621,6 +1627,7 @@ version = "0.9.3"
dependencies = [
"bitflags 2.6.0",
"convert_case",
"cow-utils",
"dashmap 6.0.1",
"globset",
"insta",

View file

@ -119,6 +119,7 @@ cfg-if = "1.0.0"
compact_str = "0.8.0"
console = "0.15.8"
convert_case = "0.6.0"
cow-utils = "0.1.3"
criterion2 = { version = "1.1.0", default-features = false }
daachorse = { version = "1.0.0" }
dashmap = "6.0.1"

View file

@ -36,6 +36,7 @@ oxc_syntax = { workspace = true }
bitflags = { workspace = true }
convert_case = { workspace = true }
cow-utils = { workspace = true }
dashmap = { workspace = true }
globset = { workspace = true }
itertools = { workspace = true }

View file

@ -1,3 +1,4 @@
use cow_utils::CowUtils;
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
@ -37,7 +38,7 @@ impl Rule for NoScriptUrl {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
match node.kind() {
AstKind::StringLiteral(literal)
if literal.value.to_lowercase().starts_with("javascript:") =>
if literal.value.cow_to_lowercase().starts_with("javascript:") =>
{
emit_diagnostic(ctx, literal.span);
}
@ -51,7 +52,7 @@ impl Rule for NoScriptUrl {
.unwrap()
.value
.raw
.to_lowercase()
.cow_to_lowercase()
.starts_with("javascript:")
{
emit_diagnostic(ctx, literal.span);