Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ itoa = "1.0.14"
javascript-globals = "1.0.0"
json-strip-comments = "1.0.4"
language-tags = "0.3.2"
lazy-regex = "3.4.1"
lazy_static = "1.5.0"
log = "0.4.25"
markdown = "1.0.0-alpha.22"
Expand All @@ -205,7 +206,6 @@ pico-args = "0.5.0"
prettyplease = "0.2.29"
project-root = "0.2.2"
rayon = "1.10.0"
regex = "1.11.1"
ropey = "1.6.1"
rust-lapper = "1.1.0"
ryu-js = "1.0.1"
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mimalloc-safe = { workspace = true, optional = true, features = ["skip_collect_o

[dev-dependencies]
insta = { workspace = true }
regex = { workspace = true }
lazy-regex = { workspace = true }

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/src/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::runner::Runner;
#[cfg(test)]
use cow_utils::CowUtils;
#[cfg(test)]
use regex::Regex;
use lazy_regex::Regex;
#[cfg(test)]
use std::{env, path::PathBuf};
#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ itertools = { workspace = true }
javascript-globals = { workspace = true }
json-strip-comments = { workspace = true }
language-tags = { workspace = true }
lazy-regex = { workspace = true }
lazy_static = { workspace = true }
memchr = { workspace = true }
nonmax = { workspace = true }
phf = { workspace = true, features = ["macros"] }
rayon = { workspace = true }
regex = { workspace = true }
rust-lapper = { workspace = true }
rustc-hash = { workspace = true }
schemars = { workspace = true, features = ["indexmap2"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/default_case.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use lazy_regex::{Regex, RegexBuilder};
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use regex::{Regex, RegexBuilder};

use crate::{AstNode, context::LintContext, rule::Rule};

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/new_cap.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::{AstNode, context::LintContext, rule::Rule};
use lazy_regex::Regex;
use oxc_ast::{
AstKind,
ast::{ChainElement, ComputedMemberExpression, Expression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{CompactStr, GetSpan, Span};
use regex::Regex;

fn new_cap_diagnostic(span: Span, cap: &GetCapResult) -> OxcDiagnostic {
let msg = if *cap == GetCapResult::Lower {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_fallthrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::ops::Range;

use cow_utils::CowUtils;
use itertools::Itertools;
use lazy_regex::Regex;
use oxc_ast::{
AstKind,
ast::{Statement, SwitchCase, SwitchStatement},
Expand All @@ -16,7 +17,6 @@ use oxc_cfg::{
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use regex::Regex;
use rustc_hash::{FxHashMap, FxHashSet};

use crate::{AstNode, context::LintContext, rule::Rule};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use lazy_static::lazy_static;
use lazy_regex::{Captures, Lazy, Regex, lazy_regex};
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use regex::{Captures, Regex};

use crate::{AstNode, context::LintContext, rule::Rule};

Expand Down Expand Up @@ -93,13 +92,11 @@ fn quick_test(s: &str) -> bool {
false
}

static NONOCTAL_REGEX: Lazy<Regex> =
lazy_regex!(r"(?:[^\\]|(?P<previousEscape>\\.))*?(?P<decimalEscape>\\[89])");

#[expect(clippy::cast_possible_truncation)]
fn check_string(ctx: &LintContext<'_>, string: &str) {
lazy_static! {
static ref NONOCTAL_REGEX: Regex =
Regex::new(r"(?:[^\\]|(?P<previousEscape>\\.))*?(?P<decimalEscape>\\[89])").unwrap();
}

// Need at least 2 characters
if string.len() <= 1 {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use ignore::gitignore::GitignoreBuilder;
use lazy_regex::Regex;
use oxc_ast::{
AstKind,
ast::{ImportOrExportKind, StringLiteral, TSImportEqualsDeclaration, TSModuleReference},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{CompactStr, Span};
use regex::Regex;
use rustc_hash::FxHashMap;
use serde::{Deserialize, Deserializer, de::Error};
use serde_json::Value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use lazy_regex::Regex;
use oxc_ast::{
AstKind,
ast::{
Expand All @@ -6,7 +7,6 @@ use oxc_ast::{
ObjectAssignmentTarget,
},
};
use regex::Regex;

use super::{NoUnusedVars, Symbol, options::IgnorePattern};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{borrow::Cow, ops::Deref};

use lazy_regex::{Regex, RegexBuilder};
use oxc_diagnostics::OxcDiagnostic;
use regex::Regex;
use serde_json::Value;

/// See [ESLint - no-unused-vars config schema](https://github.com/eslint/eslint/blob/53b1ff047948e36682fade502c949f4e371e53cd/lib/rules/no-unused-vars.js#L61)
Expand Down Expand Up @@ -290,15 +290,13 @@ where
}

impl TryFrom<Option<&str>> for IgnorePattern<Regex> {
type Error = regex::Error;
type Error = lazy_regex::regex::Error;

fn try_from(value: Option<&str>) -> Result<Self, Self::Error> {
match value {
None => Ok(Self::None),
Some("^_") => Ok(Self::Default),
Some(pattern) => {
regex::RegexBuilder::new(pattern).unicode(true).build().map(Self::Some)
}
Some(pattern) => RegexBuilder::new(pattern).build().map(Self::Some),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jest/expect_expect.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use cow_utils::CowUtils;
use lazy_regex::Regex;
use oxc_ast::{
AstKind,
ast::{CallExpression, Expression, Statement},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{CompactStr, GetSpan, Span};
use regex::Regex;
use rustc_hash::FxHashSet;

use crate::{
Expand Down
12 changes: 5 additions & 7 deletions crates/oxc_linter/src/rules/jest/no_commented_out_tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use lazy_static::lazy_static;
use lazy_regex::{Lazy, Regex, lazy_regex};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use regex::Regex;

use crate::{context::LintContext, rule::Rule};

Expand Down Expand Up @@ -53,13 +52,12 @@ declare_oxc_lint!(
suspicious
);

// /^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\(/mu
static RE: Lazy<Regex> =
lazy_regex!(r#"(?mu)^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\("#);

impl Rule for NoCommentedOutTests {
fn run_once(&self, ctx: &LintContext) {
lazy_static! {
// /^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\(/mu
static ref RE: Regex =
Regex::new(r#"(?mu)^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\("#).unwrap();
}
let comments = ctx.comments();
let commented_tests = comments.iter().filter_map(|comment| {
let text = ctx.source_range(comment.content_span());
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jest/no_large_snapshots.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::{ops::Deref, path::Path};

use lazy_regex::Regex;
use oxc_ast::{
AstKind,
ast::{Expression, ExpressionStatement, MemberExpression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{CompactStr, GetSpan, Span};
use regex::Regex;
use rustc_hash::FxHashMap;

use crate::{
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/jest/valid_title.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::hash::Hash;

use cow_utils::CowUtils;
use lazy_regex::Regex;
use oxc_ast::{
AstKind,
ast::{Argument, BinaryExpression, Expression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{CompactStr, GetSpan, Span};
use regex::Regex;
use rustc_hash::FxHashMap;

use crate::{
Expand Down Expand Up @@ -309,7 +309,7 @@ fn validate_title(
}

if !valid_title.disallowed_words.is_empty() {
let Ok(disallowed_words_reg) = regex::Regex::new(&format!(
let Ok(disallowed_words_reg) = Regex::new(&format!(
r"(?iu)\b(?:{})\b",
valid_title.disallowed_words.join("|").cow_replace('.', r"\.")
)) else {
Expand Down
Loading