Skip to content

Commit

Permalink
chore: resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
shulaoda committed Jan 31, 2025
1 parent e3866f5 commit 3aefba2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
37 changes: 6 additions & 31 deletions apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,6 @@ impl Runner for LintRunner {
let provided_path_count = paths.len();
let now = Instant::now();

// 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.
// To accommodate this, unless `--no-ignore` is passed,
// pre-filter the paths.
if !paths.is_empty() && !ignore_options.no_ignore {
let (ignore, _err) = Gitignore::new(&ignore_options.ignore_path);
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| self.cwd.join(x)).collect();

if paths.is_empty() {
// If explicit paths were provided, but all have been
// filtered, return early.
if provided_path_count > 0 {
return CliRunResult::LintNoFilesFound;
}

paths.push(self.cwd.clone());
}

let filter = match Self::get_filters(filter) {
Ok(filter) => filter,
Err((result, message)) => {
Expand Down Expand Up @@ -171,8 +148,7 @@ impl Runner for LintRunner {
// If explicit paths were provided, but all have been
// filtered, return early.
if provided_path_count > 0 {
// ToDo: when oxc_linter (config) validates the configuration, we can use exit_code = 1 to fail
return CliRunResult::LintResult(LintResult::default());
return CliRunResult::LintNoFilesFound;
}

paths.push(self.cwd.clone());
Expand Down Expand Up @@ -772,11 +748,11 @@ mod test {

#[test]
fn test_ignore_patterns() {
let result = Tester::new()
.with_cwd("fixtures/config_ignore_patterns/with_oxlintrc".into())
.get_lint_result(&["-c", "./test/eslintrc.json", "--ignore-pattern", "*.ts", "."]);
let args = &["-c", "./test/eslintrc.json", "--ignore-pattern", "*.ts", "."];

assert_eq!(result.number_of_files, 1);
Tester::new()
.with_cwd("fixtures/config_ignore_patterns/with_oxlintrc".into())
.test_and_snapshot(args);
}

#[test]
Expand All @@ -797,9 +773,8 @@ mod test {
"fixtures/config_ignore_patterns/ignore_extension/eslintrc.json",
"fixtures/config_ignore_patterns/ignore_extension/main.js",
];
let result = Tester::new().get_lint_result(args);

assert_eq!(result.number_of_files, 0);
Tester::new().test_and_snapshot(args);
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/config_ignore_patterns/ignore_extension/eslintrc.json fixtures/config_ignore_patterns/ignore_extension/main.js
working directory:
----------
----------
CLI result: LintNoFilesFound
----------
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c ./test/eslintrc.json --ignore-pattern *.ts .
working directory: fixtures/config_ignore_patterns/with_oxlintrc
----------

! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-empty-file.html\eslint-plugin-unicorn(no-empty-file)]8;;\: Empty files are not allowed.
,-[main.js:1:1]
`----
help: Delete this file or add some code to it.
Found 1 warning and 0 errors.
Finished in <variable>ms on 1 file with 97 rules using 1 threads.
----------
CLI result: LintSucceeded
----------

0 comments on commit 3aefba2

Please sign in to comment.