Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { EnumValue } from '~/subdir/enum';

const key = EnumValue.Value;

console.log(key);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"noEmit": true,
"paths": {
"~/*": ["./*"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./tsconfig.base.json"
}
9 changes: 9 additions & 0 deletions apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,4 +1395,13 @@ mod test {
let args = &["--type-aware"];
Tester::new().with_cwd("fixtures/tsgolint_config_error".into()).test_and_snapshot(args);
}

#[test]
#[cfg(all(not(target_os = "windows"), not(target_endian = "big")))]
fn test_tsgolint_tsconfig_extends_config_err() {
let args = &["--type-aware", "-D", "no-floating-promises"];
Tester::new()
.with_cwd("fixtures/tsgolint_tsconfig_extends_config_err".into())
.test_and_snapshot(args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: --type-aware -D no-floating-promises
working directory: fixtures/tsgolint_tsconfig_extends_config_err
----------

x typescript(tsconfig-error): Invalid tsconfig
help: Option 'baseUrl' has been removed. Please remove it from your configuration.
See https://github.com/oxc-project/tsgolint/issues/351 for more information.

Found 0 warnings and 1 error.
Finished in <variable>ms on 1 file with 103 rules using 1 threads.
----------
CLI result: LintFoundErrors
----------
17 changes: 11 additions & 6 deletions crates/oxc_linter/src/tsgolint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ impl<'de> Deserialize<'de> for DiagnosticKind {
#[derive(Debug, Clone, Serialize, Deserialize)]
struct TsGoLintDiagnosticPayload {
pub kind: DiagnosticKind,
pub range: Range,
pub range: Option<Range>,
pub message: RuleMessage,
pub file_path: Option<String>,
// Only for kind="rule"
Expand Down Expand Up @@ -691,7 +691,7 @@ pub struct TsGoLintRuleDiagnostic {
#[derive(Debug, Clone)]
pub struct TsGoLintInternalDiagnostic {
pub message: RuleMessage,
pub range: Range,
pub range: Option<Range>,
pub file_path: Option<PathBuf>,
}

Expand Down Expand Up @@ -727,8 +727,10 @@ impl From<TsGoLintInternalDiagnostic> for OxcDiagnostic {
if let Some(help) = val.message.help {
d = d.with_help(help);
}
if val.file_path.is_some() {
d = d.with_label(Span::new(val.range.pos, val.range.end));
if val.file_path.is_some()
&& let Some(range) = val.range
{
d = d.with_label(Span::new(range.pos, range.end));
}
d
}
Expand Down Expand Up @@ -795,7 +797,7 @@ impl Message {
}

// TODO: Should this be removed and replaced with a `Span`?
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
pub struct Range {
pub pos: u32,
pub end: u32,
Expand Down Expand Up @@ -989,7 +991,10 @@ fn parse_single_message(
rule: diagnostic_payload
.rule
.expect("Rule name must be present for rule diagnostics"),
range: diagnostic_payload.range,
range: diagnostic_payload.range.unwrap_or_else(|| {
debug_assert!(false, "Range must be present for rule diagnostics");
Range::default()
}),
message: diagnostic_payload.message,
fixes: diagnostic_payload.fixes,
suggestions: diagnostic_payload.suggestions,
Expand Down
Loading