refactor(oxlint): move cli-related exports to cli module (#5139)

This commit is contained in:
DonIsaac 2024-09-08 15:29:37 +00:00
parent f49e6ebd41
commit 20d006838e
6 changed files with 21 additions and 16 deletions

View file

@ -4,9 +4,12 @@ mod result;
mod runner; mod runner;
mod walk; mod walk;
pub mod cli {
pub use crate::{ pub use crate::{
command::*, command::*,
lint::LintRunner, lint::LintRunner,
result::{CliRunResult, LintResult}, result::{CliRunResult, LintResult},
runner::Runner, runner::Runner,
}; };
}

View file

@ -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"];

View file

@ -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()
} }

View file

@ -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 {

View file

@ -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() {

View file

@ -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);
}); });