Skip to content

Commit 7f4b576

Browse files
Sysixtaearls
authored andcommitted
refactor(oxlint): pass DiagnosticService as a parameter for TsGoLintState.lint() (oxc-project#13004)
Started to refactor for the language server, but noticed it needs more to be done: oxc-project/tsgolint#71 Still opened the PR to align with the service: https://github.com/oxc-project/oxc/blob/ca91a261556d88cde7ece4314d905a78aca1cc76/crates/oxc_linter/src/service/mod.rs#L91-L102
1 parent f4f4844 commit 7f4b576

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

apps/oxlint/src/lint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ impl LintRunner {
307307
if let Some(ret) = self
308308
.options
309309
.type_aware
310-
.then(|| TsGoLintState::new(tx_error.clone(), config_store.clone(), &paths, &options))
311-
.and_then(|s| s.lint(stdout))
310+
.then(|| TsGoLintState::new(config_store.clone(), &paths, &options))
311+
.and_then(|s| s.lint(tx_error.clone(), stdout))
312312
{
313313
return ret;
314314
}

apps/oxlint/src/tsgolint.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,15 @@ pub struct TsGoLintState<'a> {
2929
paths: &'a Vec<Arc<OsStr>>,
3030
/// The configuration store for `tsgolint` (used to resolve configurations outside of `oxc_linter`)
3131
config_store: ConfigStore,
32-
/// Channel to send errors from `tsgolint` to the main thread
33-
error_sender: DiagnosticSender,
3432
}
3533

3634
impl<'a> TsGoLintState<'a> {
3735
pub fn new(
38-
error_sender: DiagnosticSender,
3936
config_store: ConfigStore,
4037
paths: &'a Vec<Arc<OsStr>>,
4138
options: &LintServiceOptions,
4239
) -> Self {
4340
TsGoLintState {
44-
error_sender,
4541
config_store,
4642
executable_path: try_find_tsgolint_executable(options.cwd())
4743
.unwrap_or(PathBuf::from("tsgolint")),
@@ -50,7 +46,11 @@ impl<'a> TsGoLintState<'a> {
5046
}
5147
}
5248

53-
pub fn lint(self, stdout: &mut dyn Write) -> Option<CliRunResult> {
49+
pub fn lint(
50+
self,
51+
error_sender: DiagnosticSender,
52+
stdout: &mut dyn Write,
53+
) -> Option<CliRunResult> {
5454
if self.paths.is_empty() {
5555
return None;
5656
}
@@ -172,7 +172,7 @@ impl<'a> TsGoLintState<'a> {
172172
&read_to_string(&file_path).unwrap_or_else(|_| String::new()),
173173
diagnostics,
174174
);
175-
self.error_sender
175+
error_sender
176176
.send((file_path.clone(), diagnostics))
177177
.expect("Failed to send diagnostic");
178178
}

0 commit comments

Comments
 (0)