mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
feat(cli): run oxlint with no file arguments (#1201)
closes #1190 See: `https://github.com/eslint/eslint/issues/14308`
This commit is contained in:
parent
a503586d3e
commit
d82ba5b523
5 changed files with 26 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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].
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"];
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue