Skip to content

Commit

Permalink
refactor(linter): remove once_cell (#7510)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Nov 27, 2024
1 parent 60a8b9f commit 6e48059
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ mime_guess = "2.0.5"
nonmax = "0.5.5"
num-bigint = "0.4.6"
num-traits = "0.2.19"
once_cell = "1.20.2"
oxc-browserslist = "1.1.0"
oxc_index = "1.0.0"
oxc_resolver = "2.0.0"
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_linter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ lazy_static = { workspace = true }
memchr = { workspace = true }
mime_guess = { workspace = true }
nonmax = { workspace = true }
once_cell = { workspace = true }
phf = { workspace = true, features = ["macros"] }
rayon = { workspace = true }
regex = { workspace = true }
Expand Down
13 changes: 7 additions & 6 deletions crates/oxc_linter/src/rules/jsx_a11y/prefer_tag_over_role.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use once_cell::sync::Lazy;
use lazy_static::lazy_static;
use phf::phf_map;

use oxc_ast::{
ast::{JSXAttributeItem, JSXAttributeValue},
AstKind,
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use phf::phf_map;

use crate::{
context::LintContext,
Expand Down Expand Up @@ -78,16 +79,16 @@ impl PreferTagOverRole {
}
}

static ROLE_TO_TAG_MAP: Lazy<phf::Map<&'static str, &'static str>> = Lazy::new(|| {
phf_map! {
lazy_static! {
static ref ROLE_TO_TAG_MAP: phf::Map<&'static str, &'static str> = phf_map! {
"checkbox" => "input",
"button" => "button",
"heading" => "h1,h2,h3,h4,h5,h6",
"link" => "a,area",
"rowgroup" => "tbody,tfoot,thead",
"banner" => "header",
}
});
};
}

impl Rule for PreferTagOverRole {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
Expand Down
10 changes: 5 additions & 5 deletions crates/oxc_linter/src/rules/react/no_unknown_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::Cow;

use cow_utils::CowUtils;
use itertools::Itertools;
use once_cell::sync::Lazy;
use lazy_static::lazy_static;
use oxc_ast::{
ast::{JSXAttributeItem, JSXAttributeName, JSXElementName},
AstKind,
Expand Down Expand Up @@ -425,12 +425,12 @@ const DOM_PROPERTIES_IGNORE_CASE: [&str; 5] = [
"webkitDirectory",
];

static DOM_PROPERTIES_LOWER_MAP: Lazy<FxHashMap<String, &'static str>> = Lazy::new(|| {
DOM_PROPERTIES_NAMES
lazy_static! {
static ref DOM_PROPERTIES_LOWER_MAP: FxHashMap<String, &'static str> = DOM_PROPERTIES_NAMES
.iter()
.map(|it| (it.cow_to_lowercase().into_owned(), *it))
.collect::<FxHashMap<_, _>>()
});
.collect::<FxHashMap<_, _>>();
}

/// Checks if an attribute name is a valid `data-*` attribute:
/// - Name starts with "data-" and has alphanumeric words (browsers require lowercase, but React and TS lowercase them),
Expand Down

0 comments on commit 6e48059

Please sign in to comment.