From 1d1a365426c9dd0d29ee3ed953a7917b2f86d855 Mon Sep 17 00:00:00 2001 From: Don Isaac Date: Fri, 23 Aug 2024 13:18:12 -0400 Subject: [PATCH] refactor(oxlint): move cli-related exports to `cli` module --- apps/oxlint/src/lib.rs | 15 +++++++++------ apps/oxlint/src/lint/mod.rs | 8 +++++--- apps/oxlint/src/main.rs | 4 ++-- apps/oxlint/src/runner.rs | 2 +- apps/oxlint/src/walk.rs | 4 ++-- tasks/website/src/linter/cli.rs | 4 ++-- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/apps/oxlint/src/lib.rs b/apps/oxlint/src/lib.rs index a98163f4db127..75a5315df3067 100644 --- a/apps/oxlint/src/lib.rs +++ b/apps/oxlint/src/lib.rs @@ -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, + }; +} diff --git a/apps/oxlint/src/lint/mod.rs b/apps/oxlint/src/lint/mod.rs index e19d40bbbac73..efa90a242d16e 100644 --- a/apps/oxlint/src/lint/mod.rs +++ b/apps/oxlint/src/lint/mod.rs @@ -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 { @@ -184,7 +186,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"]; diff --git a/apps/oxlint/src/main.rs b/apps/oxlint/src/main.rs index c5f94bfc0623e..867f1e1aa247f 100644 --- a/apps/oxlint/src/main.rs +++ b/apps/oxlint/src/main.rs @@ -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() } diff --git a/apps/oxlint/src/runner.rs b/apps/oxlint/src/runner.rs index a757fe3efec81..46fdd11b514a3 100644 --- a/apps/oxlint/src/runner.rs +++ b/apps/oxlint/src/runner.rs @@ -1,4 +1,4 @@ -use crate::CliRunResult; +use crate::cli::CliRunResult; /// A trait for exposing functionality to the CLI. pub trait Runner { diff --git a/apps/oxlint/src/walk.rs b/apps/oxlint/src/walk.rs index e22e07a9d9466..7c10bacd0d3f6 100644 --- a/apps/oxlint/src/walk.rs +++ b/apps/oxlint/src/walk.rs @@ -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() { diff --git a/tasks/website/src/linter/cli.rs b/tasks/website/src/linter/cli.rs index e017847b467a5..67d1209614919 100644 --- a/tasks/website/src/linter/cli.rs +++ b/tasks/website/src/linter/cli.rs @@ -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); });