mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(linter): remove once_cell (#7510)
This commit is contained in:
parent
3539f56cac
commit
2077ff9269
5 changed files with 12 additions and 14 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1712,7 +1712,6 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
"nonmax",
|
"nonmax",
|
||||||
"once_cell",
|
|
||||||
"oxc_allocator",
|
"oxc_allocator",
|
||||||
"oxc_ast",
|
"oxc_ast",
|
||||||
"oxc_cfg",
|
"oxc_cfg",
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,6 @@ mime_guess = "2.0.5"
|
||||||
nonmax = "0.5.5"
|
nonmax = "0.5.5"
|
||||||
num-bigint = "0.4.6"
|
num-bigint = "0.4.6"
|
||||||
num-traits = "0.2.19"
|
num-traits = "0.2.19"
|
||||||
once_cell = "1.20.2"
|
|
||||||
oxc-browserslist = "1.1.0"
|
oxc-browserslist = "1.1.0"
|
||||||
oxc_index = "1.0.0"
|
oxc_index = "1.0.0"
|
||||||
oxc_resolver = "2.0.0"
|
oxc_resolver = "2.0.0"
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ lazy_static = { workspace = true }
|
||||||
memchr = { workspace = true }
|
memchr = { workspace = true }
|
||||||
mime_guess = { workspace = true }
|
mime_guess = { workspace = true }
|
||||||
nonmax = { workspace = true }
|
nonmax = { workspace = true }
|
||||||
once_cell = { workspace = true }
|
|
||||||
phf = { workspace = true, features = ["macros"] }
|
phf = { workspace = true, features = ["macros"] }
|
||||||
rayon = { workspace = true }
|
rayon = { workspace = true }
|
||||||
regex = { workspace = true }
|
regex = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
use once_cell::sync::Lazy;
|
use lazy_static::lazy_static;
|
||||||
|
use phf::phf_map;
|
||||||
|
|
||||||
use oxc_ast::{
|
use oxc_ast::{
|
||||||
ast::{JSXAttributeItem, JSXAttributeValue},
|
ast::{JSXAttributeItem, JSXAttributeValue},
|
||||||
AstKind,
|
AstKind,
|
||||||
|
|
@ -6,7 +8,6 @@ use oxc_ast::{
|
||||||
use oxc_diagnostics::OxcDiagnostic;
|
use oxc_diagnostics::OxcDiagnostic;
|
||||||
use oxc_macros::declare_oxc_lint;
|
use oxc_macros::declare_oxc_lint;
|
||||||
use oxc_span::Span;
|
use oxc_span::Span;
|
||||||
use phf::phf_map;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
context::LintContext,
|
context::LintContext,
|
||||||
|
|
@ -78,16 +79,16 @@ impl PreferTagOverRole {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ROLE_TO_TAG_MAP: Lazy<phf::Map<&'static str, &'static str>> = Lazy::new(|| {
|
lazy_static! {
|
||||||
phf_map! {
|
static ref ROLE_TO_TAG_MAP: phf::Map<&'static str, &'static str> = phf_map! {
|
||||||
"checkbox" => "input",
|
"checkbox" => "input",
|
||||||
"button" => "button",
|
"button" => "button",
|
||||||
"heading" => "h1,h2,h3,h4,h5,h6",
|
"heading" => "h1,h2,h3,h4,h5,h6",
|
||||||
"link" => "a,area",
|
"link" => "a,area",
|
||||||
"rowgroup" => "tbody,tfoot,thead",
|
"rowgroup" => "tbody,tfoot,thead",
|
||||||
"banner" => "header",
|
"banner" => "header",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
impl Rule for PreferTagOverRole {
|
impl Rule for PreferTagOverRole {
|
||||||
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
|
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::borrow::Cow;
|
||||||
|
|
||||||
use cow_utils::CowUtils;
|
use cow_utils::CowUtils;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use once_cell::sync::Lazy;
|
use lazy_static::lazy_static;
|
||||||
use oxc_ast::{
|
use oxc_ast::{
|
||||||
ast::{JSXAttributeItem, JSXAttributeName, JSXElementName},
|
ast::{JSXAttributeItem, JSXAttributeName, JSXElementName},
|
||||||
AstKind,
|
AstKind,
|
||||||
|
|
@ -425,12 +425,12 @@ const DOM_PROPERTIES_IGNORE_CASE: [&str; 5] = [
|
||||||
"webkitDirectory",
|
"webkitDirectory",
|
||||||
];
|
];
|
||||||
|
|
||||||
static DOM_PROPERTIES_LOWER_MAP: Lazy<FxHashMap<String, &'static str>> = Lazy::new(|| {
|
lazy_static! {
|
||||||
DOM_PROPERTIES_NAMES
|
static ref DOM_PROPERTIES_LOWER_MAP: FxHashMap<String, &'static str> = DOM_PROPERTIES_NAMES
|
||||||
.iter()
|
.iter()
|
||||||
.map(|it| (it.cow_to_lowercase().into_owned(), *it))
|
.map(|it| (it.cow_to_lowercase().into_owned(), *it))
|
||||||
.collect::<FxHashMap<_, _>>()
|
.collect::<FxHashMap<_, _>>();
|
||||||
});
|
}
|
||||||
|
|
||||||
/// Checks if an attribute name is a valid `data-*` attribute:
|
/// 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),
|
/// - Name starts with "data-" and has alphanumeric words (browsers require lowercase, but React and TS lowercase them),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue