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 walk;
pub use crate::{
command::*,
lint::LintRunner,
result::{CliRunResult, LintResult},
runner::Runner,
};
pub mod cli {
pub use crate::{
command::*,
lint::LintRunner,
result::{CliRunResult, LintResult},
runner::Runner,
};
}

View file

@ -8,9 +8,11 @@ use oxc_linter::{
use oxc_span::VALID_EXTENSIONS;
use crate::{
command::{LintCommand, OutputFormat, OutputOptions, WarningOptions},
cli::{
CliRunResult, LintCommand, LintResult, MiscOptions, OutputFormat, OutputOptions, Runner,
WarningOptions,
},
walk::{Extensions, Walk},
CliRunResult, LintResult, MiscOptions, Runner,
};
pub struct LintRunner {
@ -187,7 +189,7 @@ impl LintRunner {
#[cfg(all(test, not(target_os = "windows")))]
mod test {
use super::LintRunner;
use crate::{lint_command, CliRunResult, LintResult, Runner};
use crate::cli::{lint_command, CliRunResult, LintResult, Runner};
fn test(args: &[&str]) -> LintResult {
let mut new_args = vec!["--silent"];

View file

@ -7,13 +7,13 @@ static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
use oxlint::{CliRunResult, LintRunner, Runner};
use oxlint::cli::{CliRunResult, LintRunner, Runner};
fn main() -> CliRunResult {
init_tracing();
init_miette();
let command = oxlint::lint_command().run();
let command = oxlint::cli::lint_command().run();
command.handle_threads();
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.
pub trait Runner {

View file

@ -6,7 +6,7 @@ use std::{
use ignore::{overrides::OverrideBuilder, DirEntry};
use oxc_span::VALID_EXTENSIONS;
use crate::IgnoreOptions;
use crate::cli::IgnoreOptions;
#[derive(Clone)]
pub struct Extensions(pub Vec<&'static str>);
@ -142,7 +142,7 @@ mod test {
use std::{env, ffi::OsString};
use super::{Extensions, Walk};
use crate::IgnoreOptions;
use crate::cli::IgnoreOptions;
#[test]
fn test_walk_with_extensions() {

View file

@ -1,4 +1,4 @@
use oxlint::lint_command;
use oxlint::cli::lint_command;
#[test]
fn test_cli() {
@ -10,7 +10,7 @@ fn test_cli() {
#[test]
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::assert_snapshot!(snapshot);
});