diff --git a/crates/oxc_cli/src/lint/error.rs b/crates/oxc_cli/src/lint/error.rs deleted file mode 100644 index 69207ac66..000000000 --- a/crates/oxc_cli/src/lint/error.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::{ - error::Error as STDError, - fmt::{self, Display}, - io, - path::{Path, PathBuf}, -}; - -#[derive(Debug)] -pub struct Error { - path: PathBuf, - error: io::Error, -} - -impl STDError for Error {} -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{} when accessing \"{}\"", self.error, self.path.display()) - } -} - -impl Error { - fn new(path: PathBuf, error: io::Error) -> Self { - Self { path, error } - } -} - -// allow simple conversion from io::Result using the `with_path` method -pub trait ErrorWithPath { - /// Convert an io::Result to lint::error, which allows associating a path with the error for - /// better error messages. - fn with_path(self, path: impl AsRef) -> Result; -} - -impl ErrorWithPath for io::Result { - fn with_path(self, path: impl AsRef) -> Result { - match self { - Ok(t) => Ok(t), - Err(error) => Err(Error::new(path.as_ref().to_path_buf(), error)), - } - } -} - -pub type Result = std::result::Result; diff --git a/crates/oxc_cli/src/lint/mod.rs b/crates/oxc_cli/src/lint/mod.rs index 2f1f7795b..40e974f86 100644 --- a/crates/oxc_cli/src/lint/mod.rs +++ b/crates/oxc_cli/src/lint/mod.rs @@ -1,5 +1,3 @@ -mod error; - use std::{ io::BufWriter, sync::{ @@ -8,10 +6,7 @@ use std::{ }, }; -pub use self::error::Error; - use oxc_diagnostics::DiagnosticService; -use oxc_index::assert_impl_all; use oxc_linter::{LintOptions, LintService, Linter, PathWork}; use crate::{command::LintOptions as CliLintOptions, walk::Walk, CliRunResult, Runner}; @@ -19,7 +14,6 @@ use crate::{command::LintOptions as CliLintOptions, walk::Walk, CliRunResult, Ru pub struct LintRunner { options: CliLintOptions, } -assert_impl_all!(LintRunner: Send, Sync); impl Runner for LintRunner { type Options = CliLintOptions; diff --git a/crates/oxc_cli/src/result.rs b/crates/oxc_cli/src/result.rs index 0df3b413d..6a1fa1298 100644 --- a/crates/oxc_cli/src/result.rs +++ b/crates/oxc_cli/src/result.rs @@ -7,7 +7,6 @@ use std::{ #[derive(Debug)] pub enum CliRunResult { None, - IOError(crate::lint::Error), PathNotFound { paths: Vec, }, @@ -33,10 +32,6 @@ impl Termination for CliRunResult { println!("Path {paths:?} does not exist."); ExitCode::from(1) } - Self::IOError(e) => { - println!("IO Error: {e}"); - ExitCode::from(1) - } Self::LintResult { duration, number_of_rules, diff --git a/crates/oxc_cli/src/runner.rs b/crates/oxc_cli/src/runner.rs index c45035560..a757fe3ef 100644 --- a/crates/oxc_cli/src/runner.rs +++ b/crates/oxc_cli/src/runner.rs @@ -1,7 +1,7 @@ use crate::CliRunResult; /// A trait for exposing functionality to the CLI. -pub trait Runner: Send + Sync { +pub trait Runner { type Options; fn new(matches: Self::Options) -> Self;