Skip to content

Commit 05650c0

Browse files
committed
feat(linter/type-aware): include range with tsconfig diagnostics
1 parent da7173b commit 05650c0

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

apps/oxlint/src/snapshots/[email protected]

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ arguments: --type-aware
66
working directory: fixtures/tsgolint_config_error
77
----------
88

9-
x Invalid tsconfig
10-
,-[tsconfig.json:1:1]
11-
1 | {
12-
: ^
9+
x typescript(tsconfig-error): Invalid tsconfig
10+
,-[tsconfig.json:3:9]
1311
2 | "compilerOptions": {
12+
3 | "baseUrl": ".",
13+
: ^^^^^^^^^
14+
4 | }
1415
`----
1516
help: Option 'baseUrl' has been removed. Please remove it from your configuration.
1617
See https://github.com/oxc-project/tsgolint/issues/351 for more information.

crates/oxc_linter/src/tsgolint.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ pub struct TsGoLintRuleDiagnostic {
691691
#[derive(Debug, Clone)]
692692
pub struct TsGoLintInternalDiagnostic {
693693
pub message: RuleMessage,
694+
pub range: Range,
694695
pub file_path: Option<PathBuf>,
695696
}
696697

@@ -721,12 +722,13 @@ impl From<TsGoLintRuleDiagnostic> for OxcDiagnostic {
721722
}
722723
impl From<TsGoLintInternalDiagnostic> for OxcDiagnostic {
723724
fn from(val: TsGoLintInternalDiagnostic) -> Self {
724-
let mut d = OxcDiagnostic::error(val.message.description);
725+
let mut d = OxcDiagnostic::error(val.message.description)
726+
.with_error_code("typescript", val.message.id);
725727
if let Some(help) = val.message.help {
726728
d = d.with_help(help);
727729
}
728730
if val.file_path.is_some() {
729-
d = d.with_label(Span::new(0, 0));
731+
d = d.with_label(Span::new(val.range.pos, val.range.end));
730732
}
731733
d
732734
}
@@ -1000,6 +1002,7 @@ fn parse_single_message(
10001002
DiagnosticKind::Internal => {
10011003
TsGoLintDiagnostic::Internal(TsGoLintInternalDiagnostic {
10021004
message: diagnostic_payload.message,
1005+
range: diagnostic_payload.range,
10031006
file_path: diagnostic_payload.file_path.map(PathBuf::from),
10041007
})
10051008
}

0 commit comments

Comments
 (0)