Skip to content

Commit

Permalink
perf(linter): use cow_utils::CowUtils in no_script_url
Browse files Browse the repository at this point in the history
  • Loading branch information
heygsc authored Sep 9, 2024
1 parent af6d240 commit a84d3de
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_linter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
simdutf8 = { workspace = true }
url = { workspace = true }
cow-utils = { workspace = true }

[dev-dependencies]
insta = { workspace = true }
Expand Down
5 changes: 3 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_script_url.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use cow_utils::CowUtils;
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
Expand Down Expand Up @@ -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);
}
Expand All @@ -51,7 +52,7 @@ impl Rule for NoScriptUrl {
.unwrap()
.value
.raw
.to_lowercase()
.cow_to_lowercase()
.starts_with("javascript:")
{
emit_diagnostic(ctx, literal.span);
Expand Down

0 comments on commit a84d3de

Please sign in to comment.