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,8 @@
// This disable directive is USED even when the tsgolint diagnostic has labeled ranges.
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters
export function parseYAML<T>(
input: string,
): T {
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
return input as any as T;
}
2 changes: 1 addition & 1 deletion apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ mod test {
#[test]
fn test_tsgolint_disable_directives() {
// Test that disable directives work with type-aware rules
let args = &["--type-aware", "test.ts"];
let args = &["--type-aware"];
Tester::new()
.with_cwd("fixtures/cli/tsgolint_disable_directives".into())
.test_and_snapshot(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: apps/oxlint/src/tester.rs
---
##########
arguments: --type-aware test.ts
arguments: --type-aware
working directory: fixtures/cli/tsgolint_disable_directives
----------

Expand Down Expand Up @@ -95,8 +95,54 @@ working directory: fixtures/cli/tsgolint_disable_directives
`----
help: The promise must end with a call to .catch, or end with a call to .then with a rejection handler, or be explicitly marked as ignored with the `void` operator.

Found 10 warnings and 0 errors.
Finished in <variable>ms on 1 file with 107 rules using 1 threads.
! eslint(no-unused-expressions): Expected expression to be used
,-[unused.ts:6:1]
5 | // oxlint-disable-next-line typescript/no-floating-promises
6 | myPromise
: ^^^^^^^^^
7 |
`----
help: Consider using this expression or removing it

! eslint(no-unused-expressions): Expected expression to be used
,-[unused.ts:14:1]
13 | // oxlint-disable-next-line typescript/no-unsafe-assignment
14 | myPromise
: ^^^^^^^^^
15 |
`----
help: Consider using this expression or removing it

! typescript-eslint(no-floating-promises): Promises must be awaited, add void operator to ignore.
,-[unused.ts:14:1]
13 | // oxlint-disable-next-line typescript/no-unsafe-assignment
14 | myPromise
: ^^^^^^^^^
15 |
`----
help: The promise must end with a call to .catch, or end with a call to .then with a rejection handler, or be explicitly marked as ignored with the `void` operator.

! eslint(no-unused-expressions): Expected expression to be used
,-[unused.ts:18:1]
17 | /* eslint-disable @typescript-eslint/no-floating-promises */
18 | myPromise
: ^^^^^^^^^
19 | /* eslint-enable @typescript-eslint/no-floating-promises */
`----
help: Consider using this expression or removing it

! eslint(no-unused-vars): Variable 'x' is declared but never used. Unused variables should start with a '_'.
,-[unused.ts:23:7]
22 | /* eslint-disable @typescript-eslint/no-floating-promises */
23 | const x = 1 + 2
: |
: `-- 'x' is declared here
24 | /* eslint-enable @typescript-eslint/no-floating-promises */
`----
help: Consider removing this declaration.

Found 15 warnings and 0 errors.
Finished in <variable>ms on 3 files with 107 rules using 1 threads.
----------
CLI result: LintSucceeded
----------
12 changes: 8 additions & 4 deletions crates/oxc_linter/src/tsgolint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,10 +1059,14 @@ fn should_skip_diagnostic(
path: &Path,
tsgolint_diagnostic: &TsGoLintRuleDiagnostic,
) -> bool {
let span = tsgolint_diagnostic
.labeled_ranges
.first()
.map_or(tsgolint_diagnostic.span, |range| Span::new(range.range.pos, range.range.end));
let span = if tsgolint_diagnostic.span.is_unspanned() {
tsgolint_diagnostic
.labeled_ranges
.first()
.map_or(tsgolint_diagnostic.span, |range| Span::new(range.range.pos, range.range.end))
} else {
tsgolint_diagnostic.span
};

if let Some(directives) = disable_directives_map.get(path) {
directives.contains(&tsgolint_diagnostic.rule, span)
Expand Down
Loading