diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36b012ca4db42..9d432cd071367 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -112,7 +112,7 @@ The binary is located at `./target/release/oxlint` once the project is built. Under the hood, `cargo instruments` invokes the `xcrun` command, equivalent to ```bash -xcrun xctrace record --template 'Time Profile' --output . --launch -- /path/to/oxc/target/release/oxlint --quiet . +xcrun xctrace record --template 'Time Profile' --output . --launch -- /path/to/oxc/target/release/oxlint --quiet ``` Running the command above produces the following output diff --git a/README.md b/README.md index 9da29668eead2..c0c7eb9a802b5 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ The linter is ready to catch mistakes for you. It comes with over 60 default rul To start using, install [oxlint][npm-oxlint] or via `npx`: ```bash -npx oxlint@latest . +npx oxlint@latest ``` To give you an idea of its capabilities, here is an example from the [vscode] repository, which finishes linting 4000+ files in 0.5 seconds. @@ -127,7 +127,7 @@ Unlike other linters like [ESLint], which often require intricate configurations our linter only requires a single command that you can immediately run on your codebase: ```bash -npx oxlint@latest . +npx oxlint@latest ``` We also plan to port essential plugins such as [eslint-plugin-import] and [eslint-plugin-jest]. diff --git a/crates/oxc_cli/src/lint/main.rs b/crates/oxc_cli/src/lint/main.rs index 59dc73f8de9a8..1d85eae0ea9d9 100644 --- a/crates/oxc_cli/src/lint/main.rs +++ b/crates/oxc_cli/src/lint/main.rs @@ -14,7 +14,7 @@ fn main() -> CliRunResult { init_tracing(); init_miette(); - let command = oxc_cli::lint_command().fallback_to_usage().run(); + let command = oxc_cli::lint_command().run(); command.handle_threads(); LintRunner::new(command.lint_options).run() } diff --git a/crates/oxc_cli/src/lint/mod.rs b/crates/oxc_cli/src/lint/mod.rs index 2b65dcf72aaef..4bcb8d198464d 100644 --- a/crates/oxc_cli/src/lint/mod.rs +++ b/crates/oxc_cli/src/lint/mod.rs @@ -1,4 +1,4 @@ -use std::{io::BufWriter, path::Path, vec::Vec}; +use std::{env, io::BufWriter, path::Path, vec::Vec}; use oxc_diagnostics::DiagnosticService; use oxc_linter::{LintOptions, LintService, Linter}; @@ -37,8 +37,16 @@ impl Runner for LintRunner { enable_plugins, } = self.options; + let mut paths = paths; + if paths.is_empty() { - return CliRunResult::InvalidOptions { message: "No paths provided.".to_string() }; + if let Ok(cwd) = env::current_dir() { + paths.push(cwd); + } else { + return CliRunResult::InvalidOptions { + message: "Failed to get current working directory.".to_string(), + }; + } } let now = std::time::Instant::now(); @@ -158,6 +166,16 @@ mod test { test(args); } + #[test] + fn no_arg() { + let args = &[]; + let result = test(args); + assert!(result.number_of_rules > 0); + assert_eq!(result.number_of_files, 2); + assert_eq!(result.number_of_warnings, 2); + assert_eq!(result.number_of_errors, 0); + } + #[test] fn dir() { let args = &["fixtures"]; diff --git a/npm/oxlint/README.md b/npm/oxlint/README.md index f5a5f6cae8781..62b3afd01a478 100644 --- a/npm/oxlint/README.md +++ b/npm/oxlint/README.md @@ -44,8 +44,8 @@ This is the linter for oxc. Run -* `npx --yes oxlint@latest .` in your JavaScript / TypeScript codebase and see it complete in milliseconds. No configurations are required. -* `npx oxlint@latest` --help for usage instructions. +* `npx --yes oxlint@latest` in your JavaScript / TypeScript codebase and see it complete in milliseconds. No configurations are required. +* `npx oxlint@latest --help` for usage instructions. * `npx oxlint@latest --rules` for the list of rules.