diff --git a/apps/oxlint/fixtures/issue_7566/.oxlintignore b/apps/oxlint/fixtures/issue_7566/.oxlintignore new file mode 100644 index 000000000..d3745c177 --- /dev/null +++ b/apps/oxlint/fixtures/issue_7566/.oxlintignore @@ -0,0 +1 @@ +tests/** diff --git a/apps/oxlint/fixtures/issue_7566/tests/function/main.js b/apps/oxlint/fixtures/issue_7566/tests/function/main.js new file mode 100644 index 000000000..755b6d44f --- /dev/null +++ b/apps/oxlint/fixtures/issue_7566/tests/function/main.js @@ -0,0 +1 @@ +123 == NaN; diff --git a/apps/oxlint/fixtures/issue_7566/tests/main.js b/apps/oxlint/fixtures/issue_7566/tests/main.js new file mode 100644 index 000000000..755b6d44f --- /dev/null +++ b/apps/oxlint/fixtures/issue_7566/tests/main.js @@ -0,0 +1 @@ +123 == NaN; diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index 6ca57564f..f5649f919 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -57,16 +57,6 @@ impl Runner for LintRunner { let provided_path_count = paths.len(); let now = Instant::now(); - // append cwd to all paths - paths = paths - .into_iter() - .map(|x| { - let mut path_with_cwd = self.cwd.clone(); - path_with_cwd.push(x); - path_with_cwd - }) - .collect(); - // The ignore crate whitelists explicit paths, but priority // should be given to the ignore file. Many users lint // automatically and pass a list of changed files explicitly. @@ -77,6 +67,16 @@ impl Runner for LintRunner { paths.retain(|p| if p.is_dir() { true } else { !ignore.matched(p, false).is_ignore() }); } + // Append cwd to all paths + paths = paths + .into_iter() + .map(|x| { + let mut path_with_cwd = self.cwd.clone(); + path_with_cwd.push(x); + path_with_cwd + }) + .collect(); + if paths.is_empty() { // If explicit paths were provided, but all have been // filtered, return early. @@ -777,4 +777,19 @@ mod test { ]); assert_eq!(result.number_of_files, 1); } + + // Issue: + #[test] + fn ignore_path_with_relative_files() { + let args = &[ + "--ignore-path", + "fixtures/issue_7566/.oxlintignore", + "fixtures/issue_7566/tests/main.js", + "fixtures/issue_7566/tests/function/main.js", + ]; + let result = test(args); + assert_eq!(result.number_of_files, 0); + assert_eq!(result.number_of_warnings, 0); + assert_eq!(result.number_of_errors, 0); + } }