From 4b9d8d2c4abbeda1cd2cbb0ca5e530d2690ab00a Mon Sep 17 00:00:00 2001 From: camc314 <18101008+camc314@users.noreply.github.com> Date: Thu, 20 Nov 2025 20:28:04 +0000 Subject: [PATCH] feat(linter/type-aware): include range with tsconfig diagnostics (#15916) --- ...tures__tsgolint_config_error_--type-aware@oxlint.snap | 9 +++++---- crates/oxc_linter/src/tsgolint.rs | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/oxlint/src/snapshots/fixtures__tsgolint_config_error_--type-aware@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__tsgolint_config_error_--type-aware@oxlint.snap index bafeec8762eaf..d3bc5bc8cb726 100644 --- a/apps/oxlint/src/snapshots/fixtures__tsgolint_config_error_--type-aware@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__tsgolint_config_error_--type-aware@oxlint.snap @@ -6,11 +6,12 @@ arguments: --type-aware working directory: fixtures/tsgolint_config_error ---------- - x Invalid tsconfig - ,-[tsconfig.json:1:1] - 1 | { - : ^ + x typescript(tsconfig-error): Invalid tsconfig + ,-[tsconfig.json:3:9] 2 | "compilerOptions": { + 3 | "baseUrl": ".", + : ^^^^^^^^^ + 4 | } `---- help: Option 'baseUrl' has been removed. Please remove it from your configuration. See https://github.com/oxc-project/tsgolint/issues/351 for more information. diff --git a/crates/oxc_linter/src/tsgolint.rs b/crates/oxc_linter/src/tsgolint.rs index a60d090fd9867..1a0b00010280d 100644 --- a/crates/oxc_linter/src/tsgolint.rs +++ b/crates/oxc_linter/src/tsgolint.rs @@ -691,6 +691,7 @@ pub struct TsGoLintRuleDiagnostic { #[derive(Debug, Clone)] pub struct TsGoLintInternalDiagnostic { pub message: RuleMessage, + pub range: Range, pub file_path: Option, } @@ -721,12 +722,13 @@ impl From for OxcDiagnostic { } impl From for OxcDiagnostic { fn from(val: TsGoLintInternalDiagnostic) -> Self { - let mut d = OxcDiagnostic::error(val.message.description); + let mut d = OxcDiagnostic::error(val.message.description) + .with_error_code("typescript", val.message.id); if let Some(help) = val.message.help { d = d.with_help(help); } if val.file_path.is_some() { - d = d.with_label(Span::new(0, 0)); + d = d.with_label(Span::new(val.range.pos, val.range.end)); } d } @@ -1000,6 +1002,7 @@ fn parse_single_message( DiagnosticKind::Internal => { TsGoLintDiagnostic::Internal(TsGoLintInternalDiagnostic { message: diagnostic_payload.message, + range: diagnostic_payload.range, file_path: diagnostic_payload.file_path.map(PathBuf::from), }) }