mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(oxlint): move cli-related exports to cli module (#5139)
This commit is contained in:
parent
f49e6ebd41
commit
20d006838e
6 changed files with 21 additions and 16 deletions
|
|
@ -4,9 +4,12 @@ mod result;
|
||||||
mod runner;
|
mod runner;
|
||||||
mod walk;
|
mod walk;
|
||||||
|
|
||||||
pub use crate::{
|
pub mod cli {
|
||||||
command::*,
|
|
||||||
lint::LintRunner,
|
pub use crate::{
|
||||||
result::{CliRunResult, LintResult},
|
command::*,
|
||||||
runner::Runner,
|
lint::LintRunner,
|
||||||
};
|
result::{CliRunResult, LintResult},
|
||||||
|
runner::Runner,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,11 @@ use oxc_linter::{
|
||||||
use oxc_span::VALID_EXTENSIONS;
|
use oxc_span::VALID_EXTENSIONS;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
command::{LintCommand, OutputFormat, OutputOptions, WarningOptions},
|
cli::{
|
||||||
|
CliRunResult, LintCommand, LintResult, MiscOptions, OutputFormat, OutputOptions, Runner,
|
||||||
|
WarningOptions,
|
||||||
|
},
|
||||||
walk::{Extensions, Walk},
|
walk::{Extensions, Walk},
|
||||||
CliRunResult, LintResult, MiscOptions, Runner,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct LintRunner {
|
pub struct LintRunner {
|
||||||
|
|
@ -187,7 +189,7 @@ impl LintRunner {
|
||||||
#[cfg(all(test, not(target_os = "windows")))]
|
#[cfg(all(test, not(target_os = "windows")))]
|
||||||
mod test {
|
mod test {
|
||||||
use super::LintRunner;
|
use super::LintRunner;
|
||||||
use crate::{lint_command, CliRunResult, LintResult, Runner};
|
use crate::cli::{lint_command, CliRunResult, LintResult, Runner};
|
||||||
|
|
||||||
fn test(args: &[&str]) -> LintResult {
|
fn test(args: &[&str]) -> LintResult {
|
||||||
let mut new_args = vec!["--silent"];
|
let mut new_args = vec!["--silent"];
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||||
|
|
||||||
use oxlint::{CliRunResult, LintRunner, Runner};
|
use oxlint::cli::{CliRunResult, LintRunner, Runner};
|
||||||
|
|
||||||
fn main() -> CliRunResult {
|
fn main() -> CliRunResult {
|
||||||
init_tracing();
|
init_tracing();
|
||||||
init_miette();
|
init_miette();
|
||||||
|
|
||||||
let command = oxlint::lint_command().run();
|
let command = oxlint::cli::lint_command().run();
|
||||||
command.handle_threads();
|
command.handle_threads();
|
||||||
LintRunner::new(command).run()
|
LintRunner::new(command).run()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::CliRunResult;
|
use crate::cli::CliRunResult;
|
||||||
|
|
||||||
/// A trait for exposing functionality to the CLI.
|
/// A trait for exposing functionality to the CLI.
|
||||||
pub trait Runner {
|
pub trait Runner {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use std::{
|
||||||
use ignore::{overrides::OverrideBuilder, DirEntry};
|
use ignore::{overrides::OverrideBuilder, DirEntry};
|
||||||
use oxc_span::VALID_EXTENSIONS;
|
use oxc_span::VALID_EXTENSIONS;
|
||||||
|
|
||||||
use crate::IgnoreOptions;
|
use crate::cli::IgnoreOptions;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Extensions(pub Vec<&'static str>);
|
pub struct Extensions(pub Vec<&'static str>);
|
||||||
|
|
@ -142,7 +142,7 @@ mod test {
|
||||||
use std::{env, ffi::OsString};
|
use std::{env, ffi::OsString};
|
||||||
|
|
||||||
use super::{Extensions, Walk};
|
use super::{Extensions, Walk};
|
||||||
use crate::IgnoreOptions;
|
use crate::cli::IgnoreOptions;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_walk_with_extensions() {
|
fn test_walk_with_extensions() {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use oxlint::lint_command;
|
use oxlint::cli::lint_command;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cli() {
|
fn test_cli() {
|
||||||
|
|
@ -10,7 +10,7 @@ fn test_cli() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cli_terminal() {
|
fn test_cli_terminal() {
|
||||||
let snapshot = oxlint::lint_command().run_inner(&["--help"]).unwrap_err().unwrap_stdout();
|
let snapshot = oxlint::cli::lint_command().run_inner(&["--help"]).unwrap_err().unwrap_stdout();
|
||||||
insta::with_settings!({ prepend_module_to_snapshot => false }, {
|
insta::with_settings!({ prepend_module_to_snapshot => false }, {
|
||||||
insta::assert_snapshot!(snapshot);
|
insta::assert_snapshot!(snapshot);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue