Skip to content

Commit

Permalink
fix(linter): rule no-restricted-imports support regex option inside p…
Browse files Browse the repository at this point in the history
…atterns
  • Loading branch information
Sysix committed Dec 23, 2024
1 parent acbff7b commit a955782
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crates/oxc_linter/src/rules/eslint/no_restricted_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,7 @@ impl RestrictedPattern {
_ => "iu",
};

let reg_string = format!("{}", regex.as_str());

let Ok(reg_exp) = Regex::with_flags(&reg_string, flags) else {
let Ok(reg_exp) = Regex::with_flags(regex.as_str(), flags) else {
return false;
};

Expand Down Expand Up @@ -497,7 +495,7 @@ impl NoRestrictedImports {
GlobResult::None => (),
};

if pattern.get_regex_result(&module_request) {
if pattern.get_regex_result(module_request) {
let span = module_request.span();

no_restricted_imports_diagnostic(ctx, span, pattern.message.clone(), source);
Expand Down

0 comments on commit a955782

Please sign in to comment.