diff --git a/apps/oxlint/src/lib.rs b/apps/oxlint/src/lib.rs index 74d631e15932c..9c16eb32dfd57 100644 --- a/apps/oxlint/src/lib.rs +++ b/apps/oxlint/src/lib.rs @@ -10,7 +10,6 @@ mod lint; mod output_formatter; mod result; mod tester; -mod tsgolint; mod walk; pub mod cli { diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index d703a667d82ab..7199332583e19 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -17,12 +17,12 @@ use oxc_diagnostics::{DiagnosticSender, DiagnosticService, GraphicalReportHandle use oxc_linter::{ AllowWarnDeny, Config, ConfigStore, ConfigStoreBuilder, ExternalLinter, ExternalPluginStore, InvalidFilterKind, LintFilter, LintOptions, LintService, LintServiceOptions, Linter, Oxlintrc, + TsGoLintState, }; use crate::{ cli::{CliRunResult, LintCommand, MiscOptions, ReportUnusedDirectives, WarningOptions}, output_formatter::{LintCommandInfo, OutputFormatter}, - tsgolint::TsGoLintState, walk::Walk, }; diff --git a/crates/oxc_linter/src/lib.rs b/crates/oxc_linter/src/lib.rs index f9b540cb930fb..bea97b3b7bcc2 100644 --- a/crates/oxc_linter/src/lib.rs +++ b/crates/oxc_linter/src/lib.rs @@ -26,6 +26,7 @@ mod module_record; mod options; mod rule; mod service; +mod tsgolint; mod utils; pub mod loader; @@ -57,8 +58,8 @@ pub use crate::{ options::{AllowWarnDeny, InvalidFilterKind, LintFilter, LintFilterKind}, rule::{RuleCategory, RuleFixMeta, RuleMeta}, service::{LintService, LintServiceOptions, RuntimeFileSystem}, - utils::read_to_arena_str, - utils::read_to_string, + tsgolint::TsGoLintState, + utils::{read_to_arena_str, read_to_string}, }; use crate::{ config::{LintConfig, OxlintEnv, OxlintGlobals, OxlintSettings}, diff --git a/apps/oxlint/src/tsgolint.rs b/crates/oxc_linter/src/tsgolint.rs similarity index 97% rename from apps/oxlint/src/tsgolint.rs rename to crates/oxc_linter/src/tsgolint.rs index 7502b545d1f4f..001e9cd97cb1b 100644 --- a/apps/oxlint/src/tsgolint.rs +++ b/crates/oxc_linter/src/tsgolint.rs @@ -9,11 +9,10 @@ use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use oxc_diagnostics::{DiagnosticSender, DiagnosticService, OxcDiagnostic, Severity}; -use oxc_linter::{ - AllowWarnDeny, ConfigStore, LintServiceOptions, ResolvedLinterState, read_to_string, -}; use oxc_span::{SourceType, Span}; +use super::{AllowWarnDeny, ConfigStore, LintServiceOptions, ResolvedLinterState, read_to_string}; + /// State required to initialize the `tsgolint` linter. #[derive(Debug, Clone)] pub struct TsGoLintState<'a> { @@ -42,6 +41,13 @@ impl<'a> TsGoLintState<'a> { } } + /// # Panics + /// - when `stdin` of subprocess cannot be opened + /// - when `stdout` of subprocess cannot be opened + /// - when `tsgolint` process cannot be awaited + /// + /// # Errors + /// A human-readable error message indicating why the linting failed. pub fn lint(self, error_sender: DiagnosticSender) -> Result<(), String> { if self.paths.is_empty() { return Ok(());