Skip to content

Commit

Permalink
refactor(oxlint): move cli-related exports to cli module (#5139)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac committed Sep 8, 2024
1 parent f49e6eb commit 20d0068
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
15 changes: 9 additions & 6 deletions apps/oxlint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
8 changes: 5 additions & 3 deletions apps/oxlint/src/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"];
Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::CliRunResult;
use crate::cli::CliRunResult;

/// A trait for exposing functionality to the CLI.
pub trait Runner {
Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>);
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions tasks/website/src/linter/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use oxlint::lint_command;
use oxlint::cli::lint_command;

#[test]
fn test_cli() {
Expand All @@ -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);
});
Expand Down

0 comments on commit 20d0068

Please sign in to comment.