Skip to content

Commit c910bc2

Browse files
committed
fix(linter): fix cli argument parsing
fixes #14071 Simplify CLI argument collection by unconditionally skipping the first two entries in std::env::args_os(). This ensures correct handling in wrapper scenarios (e.g., Node.js invocations via npm/pnpm) where the conditional "node" check may fail, such as with version managers like asdf. Previously, mis-skipping could lead to wrapper script paths (potentially containing "..") being passed to the CLI parser, triggering validation errors.
1 parent 2fb69fd commit c910bc2

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

apps/oxlint/src/run.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,7 @@ fn lint_impl(load_plugin: JsLoadPluginCb, lint_file: JsLintFileCb) -> CliRunResu
6666
init_tracing();
6767
init_miette();
6868

69-
let mut args = std::env::args_os();
70-
// If first arg is `node`, also skip script path (`node script.js ...`).
71-
// Otherwise, just skip first arg (`oxlint ...`).
72-
if args.next().is_some_and(|arg| arg == "node") {
73-
args.next();
74-
}
75-
let args = args.collect::<Vec<_>>();
69+
let args = std::env::args_os().skip(2).collect::<Vec<_>>();
7670

7771
let cmd = crate::cli::lint_command();
7872
let command = match cmd.run_inner(&*args) {

0 commit comments

Comments
 (0)