Skip to content

Commit cc2a85b

Browse files
committed
refactor(linter): remove CliRunResult from TsGoLintState (#13119)
Goal is there are no references for `oxlint` functions. Now move `TsGoLintState` to `oxc_linter` so the server can use it too 🥳
1 parent 23e5642 commit cc2a85b

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

apps/oxlint/src/lint.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,13 @@ impl LintRunner {
304304

305305
// Run type-aware linting through tsgolint
306306
// TODO: Add a warning message if `tsgolint` cannot be found, but type-aware rules are enabled
307-
if let Some(ret) = self
308-
.options
309-
.type_aware
310-
.then(|| TsGoLintState::new(config_store.clone(), &paths, &options))
311-
.and_then(|s| s.lint(tx_error.clone(), stdout))
312-
{
313-
return ret;
307+
if self.options.type_aware {
308+
if let Err(err) =
309+
TsGoLintState::new(config_store.clone(), &paths, &options).lint(tx_error.clone())
310+
{
311+
print_and_flush_stdout(stdout, &err);
312+
return CliRunResult::TsGoLintError;
313+
}
314314
}
315315

316316
let linter = Linter::new(LintOptions::default(), config_store, self.external_linter)

apps/oxlint/src/tsgolint.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ use oxc_linter::{
1414
};
1515
use oxc_span::{SourceType, Span};
1616

17-
use crate::cli::CliRunResult;
18-
19-
use super::lint::print_and_flush_stdout;
20-
2117
/// State required to initialize the `tsgolint` linter.
2218
#[derive(Debug, Clone)]
2319
pub struct TsGoLintState<'a> {
@@ -46,13 +42,9 @@ impl<'a> TsGoLintState<'a> {
4642
}
4743
}
4844

49-
pub fn lint(
50-
self,
51-
error_sender: DiagnosticSender,
52-
stdout: &mut dyn Write,
53-
) -> Option<CliRunResult> {
45+
pub fn lint(self, error_sender: DiagnosticSender) -> Result<(), String> {
5446
if self.paths.is_empty() {
55-
return None;
47+
return Ok(());
5648
}
5749

5850
let mut resolved_configs: FxHashMap<PathBuf, ResolvedLinterState> = FxHashMap::default();
@@ -211,16 +203,10 @@ impl<'a> TsGoLintState<'a> {
211203
match handler.join() {
212204
Ok(Ok(())) => {
213205
// Successfully ran tsgolint
214-
None
215-
}
216-
Ok(Err(err)) => {
217-
print_and_flush_stdout(stdout, &format!("Error running tsgolint: {err:?}"));
218-
Some(CliRunResult::TsGoLintError)
219-
}
220-
Err(err) => {
221-
print_and_flush_stdout(stdout, &format!("Error running tsgolint: {err:?}"));
222-
Some(CliRunResult::TsGoLintError)
206+
Ok(())
223207
}
208+
Ok(Err(err)) => Err(format!("Error running tsgolint: {err:?}")),
209+
Err(err) => Err(format!("Error running tsgolint: {err:?}")),
224210
}
225211
}
226212

0 commit comments

Comments
 (0)