diff --git a/crates/oxc_linter/src/rules/eslint/no_restricted_imports.rs b/crates/oxc_linter/src/rules/eslint/no_restricted_imports.rs index 19d8e0990917d..051241e8efa07 100644 --- a/crates/oxc_linter/src/rules/eslint/no_restricted_imports.rs +++ b/crates/oxc_linter/src/rules/eslint/no_restricted_imports.rs @@ -342,7 +342,7 @@ impl NoRestrictedImports { continue; } - let mut builder = GitignoreBuilder::new("/"); + let mut builder = GitignoreBuilder::new(""); let _ = builder.case_insensitive(!pattern.case_sensitive.unwrap_or(false)); for group in &pattern.group { @@ -356,7 +356,7 @@ impl NoRestrictedImports { let source = entry.module_request.name(); let span = entry.module_request.span(); - let matched = gitignore.matched(source, true); + let matched = gitignore.matched(source, false); // println!("{:?}", matched); if matched.is_whitelist() { @@ -840,10 +840,10 @@ fn test() { // r#"import withPatterns from "foo/bar";"#, // Some(serde_json::json!([{ "patterns": ["foo"] }])), // ), - // ( - // r#"import withPatterns from "foo/bar";"#, - // Some(serde_json::json!([{ "patterns": ["bar"] }])), - // ), + ( + r#"import withPatterns from "foo/bar";"#, + Some(serde_json::json!([{ "patterns": ["bar"] }])), + ), ( r#"import withPatterns from "foo/baz";"#, Some( diff --git a/crates/oxc_linter/src/snapshots/eslint_no_restricted_imports.snap b/crates/oxc_linter/src/snapshots/eslint_no_restricted_imports.snap index 9d213f568e089..fc8dde990dd5e 100644 --- a/crates/oxc_linter/src/snapshots/eslint_no_restricted_imports.snap +++ b/crates/oxc_linter/src/snapshots/eslint_no_restricted_imports.snap @@ -30,6 +30,13 @@ snapshot_kind: text ╰──── help: Remove the import statement. + ⚠ eslint(no-restricted-imports): 'foo/bar' import is restricted from being used. + ╭─[no_restricted_imports.tsx:1:26] + 1 │ import withPatterns from "foo/bar"; + · ───────── + ╰──── + help: Remove the import statement. + ⚠ eslint(no-restricted-imports): foo is forbidden, use foo/bar instead ╭─[no_restricted_imports.tsx:1:26] 1 │ import withPatterns from "foo/baz";