mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(linter): remove glob for windows (#8390)
The current implementations does not work. Under linux it tells me 0 files, under windows: ``` > oxc-vscode@0.15.5 lint C:\dev\oxc\editors\vscode > npx oxlint --config=oxlint.json --tsconfig=tsconfig.json client/*.js Finished in 5ms on 5 files with 101 rules using 24 threads. Found 0 warnings and 0 errors. ``` I do not think this glob is needed. we are using `ignore` in our `Walker`, which should already covering the use case. --------- Co-authored-by: Sysix <alexander.schlegel@clicksports.de> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
0a1ffc045d
commit
4e05e66d7c
6 changed files with 1 additions and 61 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -709,12 +709,6 @@ version = "0.31.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glob"
|
|
||||||
version = "0.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "globset"
|
name = "globset"
|
||||||
version = "0.4.15"
|
version = "0.4.15"
|
||||||
|
|
@ -2134,7 +2128,6 @@ name = "oxlint"
|
||||||
version = "0.15.5"
|
version = "0.15.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bpaf",
|
"bpaf",
|
||||||
"glob",
|
|
||||||
"ignore",
|
"ignore",
|
||||||
"jemallocator",
|
"jemallocator",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,6 @@ env_logger = { version = "0.11.5", default-features = false }
|
||||||
fast-glob = "0.4.0"
|
fast-glob = "0.4.0"
|
||||||
flate2 = "1.0.35"
|
flate2 = "1.0.35"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
glob = "0.3.1"
|
|
||||||
globset = "0.4.15"
|
globset = "0.4.15"
|
||||||
handlebars = "6.2.0"
|
handlebars = "6.2.0"
|
||||||
hashbrown = "0.15.2"
|
hashbrown = "0.15.2"
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ oxc_linter = { workspace = true }
|
||||||
oxc_span = { workspace = true }
|
oxc_span = { workspace = true }
|
||||||
|
|
||||||
bpaf = { workspace = true, features = ["autocomplete", "bright-color", "derive"] }
|
bpaf = { workspace = true, features = ["autocomplete", "bright-color", "derive"] }
|
||||||
glob = { workspace = true }
|
|
||||||
ignore = { workspace = true, features = ["simd-accel"] }
|
ignore = { workspace = true, features = ["simd-accel"] }
|
||||||
miette = { workspace = true }
|
miette = { workspace = true }
|
||||||
rayon = { workspace = true }
|
rayon = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ use bpaf::Bpaf;
|
||||||
use oxc_linter::{AllowWarnDeny, FixKind, LintPlugins};
|
use oxc_linter::{AllowWarnDeny, FixKind, LintPlugins};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
expand_glob,
|
|
||||||
ignore::{ignore_options, IgnoreOptions},
|
ignore::{ignore_options, IgnoreOptions},
|
||||||
misc_options, validate_paths, MiscOptions, PATHS_ERROR_MESSAGE, VERSION,
|
misc_options, validate_paths, MiscOptions, PATHS_ERROR_MESSAGE, VERSION,
|
||||||
};
|
};
|
||||||
|
|
@ -41,7 +40,7 @@ pub struct LintCommand {
|
||||||
pub misc_options: MiscOptions,
|
pub misc_options: MiscOptions,
|
||||||
|
|
||||||
/// Single file, single path or list of paths
|
/// Single file, single path or list of paths
|
||||||
#[bpaf(positional("PATH"), many, guard(validate_paths, PATHS_ERROR_MESSAGE), map(expand_glob))]
|
#[bpaf(positional("PATH"), many, guard(validate_paths, PATHS_ERROR_MESSAGE))]
|
||||||
pub paths: Vec<PathBuf>,
|
pub paths: Vec<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -480,27 +479,6 @@ mod lint_options {
|
||||||
assert_eq!(options.paths, [file_foo, file_bar, file_baz]);
|
assert_eq!(options.paths, [file_foo, file_bar, file_baz]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
#[test]
|
|
||||||
#[allow(clippy::similar_names)]
|
|
||||||
fn wildcard_expansion() {
|
|
||||||
let temp_dir = tempfile::tempdir().expect("Could not create a temp dir");
|
|
||||||
let file_foo = temp_dir.path().join("foo.js");
|
|
||||||
File::create(&file_foo).expect("Could not create foo.js temp file");
|
|
||||||
let file_bar = temp_dir.path().join("bar.js");
|
|
||||||
File::create(&file_bar).expect("Could not create bar.js temp file");
|
|
||||||
let file_baz = temp_dir.path().join("baz");
|
|
||||||
File::create(&file_baz).expect("Could not create baz temp file");
|
|
||||||
|
|
||||||
let js_files_wildcard = temp_dir.path().join("*.js");
|
|
||||||
let options = get_lint_options(
|
|
||||||
js_files_wildcard.to_str().expect("could not get js files wildcard path"),
|
|
||||||
);
|
|
||||||
assert!(options.paths.contains(&file_foo));
|
|
||||||
assert!(options.paths.contains(&file_bar));
|
|
||||||
assert!(!options.paths.contains(&file_baz));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_parent_path() {
|
fn no_parent_path() {
|
||||||
match lint_command().run_inner(&["../parent_dir"]) {
|
match lint_command().run_inner(&["../parent_dir"]) {
|
||||||
|
|
|
||||||
|
|
@ -43,31 +43,6 @@ fn validate_paths(paths: &Vec<PathBuf>) -> bool {
|
||||||
|
|
||||||
const PATHS_ERROR_MESSAGE: &str = "PATH must not contain \"..\"";
|
const PATHS_ERROR_MESSAGE: &str = "PATH must not contain \"..\"";
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
#[allow(clippy::needless_pass_by_value)]
|
|
||||||
fn expand_glob(paths: Vec<PathBuf>) -> Vec<PathBuf> {
|
|
||||||
let match_options = glob::MatchOptions {
|
|
||||||
case_sensitive: true,
|
|
||||||
require_literal_separator: false,
|
|
||||||
require_literal_leading_dot: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
paths
|
|
||||||
.iter()
|
|
||||||
.filter_map(|path| path.to_str())
|
|
||||||
.filter_map(|path| glob::glob_with(path, match_options).ok())
|
|
||||||
.flatten()
|
|
||||||
.filter_map(Result::ok)
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
|
||||||
#[allow(clippy::needless_pass_by_value)]
|
|
||||||
fn expand_glob(paths: Vec<PathBuf>) -> Vec<PathBuf> {
|
|
||||||
// no-op on any os other than windows, since they expand globs
|
|
||||||
paths
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod misc_options {
|
mod misc_options {
|
||||||
use super::{lint::lint_command, MiscOptions};
|
use super::{lint::lint_command, MiscOptions};
|
||||||
|
|
|
||||||
|
|
@ -365,8 +365,6 @@ mod test {
|
||||||
assert_eq!(result.number_of_errors, 0);
|
assert_eq!(result.number_of_errors, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// exclude because we are working with Glob, which only supports the current working directory
|
|
||||||
#[cfg(all(test, not(target_os = "windows")))]
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cwd() {
|
fn cwd() {
|
||||||
let args = &["debugger.js"];
|
let args = &["debugger.js"];
|
||||||
|
|
@ -395,8 +393,6 @@ mod test {
|
||||||
assert_eq!(result.number_of_errors, 0);
|
assert_eq!(result.number_of_errors, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDo: lints all files under windows
|
|
||||||
#[cfg(all(test, not(target_os = "windows")))]
|
|
||||||
#[test]
|
#[test]
|
||||||
fn wrong_extension() {
|
fn wrong_extension() {
|
||||||
let args = &["foo.asdf"];
|
let args = &["foo.asdf"];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue