Skip to content

Commit

Permalink
refactor(diagnostics): configure miette properly and remove customiza…
Browse files Browse the repository at this point in the history
…tion code
  • Loading branch information
Boshen committed Dec 23, 2023
1 parent b25f014 commit e490497
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 1,156 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions crates/oxc_cli/src/format/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
use oxc_cli::{CliRunResult, FormatRunner, Runner};

fn main() -> CliRunResult {
init_miette();
oxc_diagnostics::init_miette();

let command = oxc_cli::format_command().fallback_to_usage().run();
command.handle_threads();
FormatRunner::new(command.format_options).run()
}

// Initialize the data which relies on `is_atty` system calls so they don't block subsequent threads.
fn init_miette() {
miette::set_hook(Box::new(|_| Box::new(miette::MietteHandlerOpts::new().build()))).unwrap();
}
7 changes: 1 addition & 6 deletions crates/oxc_cli/src/lint/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,13 @@ use oxc_cli::{CliRunResult, LintRunner, Runner};

fn main() -> CliRunResult {
init_tracing();
init_miette();
oxc_diagnostics::init_miette();

let command = oxc_cli::lint_command().run();
command.handle_threads();
LintRunner::new(command.lint_options).run()
}

// Initialize the data which relies on `is_atty` system calls so they don't block subsequent threads.
fn init_miette() {
miette::set_hook(Box::new(|_| Box::new(miette::MietteHandlerOpts::new().build()))).unwrap();
}

fn init_tracing() {
use tracing_subscriber::{fmt, prelude::*, registry, EnvFilter};
registry().with(fmt::layer()).with(EnvFilter::from_env("OXC_LOG")).init();
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_cli/src/lint/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{env, io::BufWriter, path::Path, vec::Vec};

use oxc_diagnostics::{DiagnosticService, GraphicalReportHandler};
use oxc_diagnostics::{miette::GraphicalReportHandler, DiagnosticService};
use oxc_linter::{LintOptions, LintService, Linter};

use crate::{
Expand Down
3 changes: 0 additions & 3 deletions crates/oxc_diagnostics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,4 @@ doctest = false
thiserror = { workspace = true }
miette = { workspace = true }

unicode-width = "0.1.11"
owo-colors = { version = "3.5.0" }
textwrap = { version = "=0.15.0" } # pinned to 0.15.0 to sync with miette
is-terminal = { version = "0.4.9" }
Loading

0 comments on commit e490497

Please sign in to comment.