Skip to content

Commit

Permalink
fix(linter): ignore paths on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 committed Dec 31, 2024
1 parent e5ee38f commit 6984965
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
fail-fast: false
matrix:
include:
# - os: windows-latest # See `test-windows` job below
- os: windows-latest # See `test-windows` job below
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
Expand All @@ -42,9 +42,10 @@ jobs:
# cache `target` directory to avoid download crates
save-cache: ${{ github.ref_name == 'main' }}
cache-key: warm
- run: cargo ck
- run: cargo test
- run: git diff --exit-code # Must commit everything
- run: cargo test --package oxlint --lib -- lint::test --show-output
# - run: cargo ck
# - run: cargo test
# - run: git diff --exit-code # Must commit everything

test-windows:
name: Test (windows-latest)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ignorePatterns": [
"src/bad.js"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("hello world");
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (true) {
console.log("true");
}
27 changes: 24 additions & 3 deletions apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ impl Runner for LintRunner {
.iter()
.map(|value| oxlintrc.path.parent().unwrap().join(value))
.collect::<Vec<_>>();
dbg!(&paths);
let paths = Walk::new(&paths, &ignore_options, &ignore_paths)
.with_extensions(Extensions(extensions))
.paths();

dbg!(&ignore_paths);
dbg!(&paths);

let number_of_files = paths.len();

enable_plugins.apply_overrides(&mut oxlintrc.plugins);
Expand Down Expand Up @@ -281,7 +285,7 @@ impl LintRunner {
}
}

#[cfg(all(test, not(target_os = "windows")))]
#[cfg(test)]
mod test {
use std::env;

Expand Down Expand Up @@ -727,8 +731,11 @@ mod test {
panic!("Expected PrintConfigResult, got {ret:?}")
};

let expect_json =
std::fs::read_to_string("fixtures/print_config/ban_rules/expect.json").unwrap();
#[expect(clippy::disallowed_methods)]
let expect_json = std::fs::read_to_string("fixtures/print_config/ban_rules/expect.json")
.unwrap()
.replace("\r\n", "\n");

assert_eq!(config, expect_json.trim());
}

Expand Down Expand Up @@ -842,4 +849,18 @@ mod test {
assert_eq!(result.number_of_warnings, 0);
assert_eq!(result.number_of_errors, 1);
}

#[test]
fn foo() {
let args = &[
"-c",
"fixtures/config_ignore_patterns_windows/oxlint.json",
"fixtures/config_ignore_patterns_windows/",
];
let result = test(args);

assert_eq!(result.number_of_files, 1);
assert_eq!(result.number_of_warnings, 1);
assert_eq!(result.number_of_errors, 0);
}
}

0 comments on commit 6984965

Please sign in to comment.