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
10 changes: 10 additions & 0 deletions apps/oxlint/fixtures/tsgolint/no-unnecessary-condition.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
declare const b1: object;
declare const b2: boolean;
export const t1 = b1 && b2;

function checkNumber(x: number) {
// eslint-disable-next-line typescript/no-unnecessary-condition
if (x != null) {
return x;
}
return 0;
}

checkNumber(1);
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,15 @@ working directory: fixtures/tsgolint
2 | declare const b2: boolean;
3 | export const t1 = b1 && b2;
: ^^
4 |
`----

x typescript-eslint(strict-boolean-expressions): Unexpected object value in conditional. An object is always truthy.
,-[no-unnecessary-condition.ts:3:19]
2 | declare const b2: boolean;
3 | export const t1 = b1 && b2;
: ^^
4 |
`----

x typescript-eslint(no-unnecessary-qualifier): Qualifier is unnecessary since 'B' is in scope.
Expand Down
5 changes: 4 additions & 1 deletion crates/oxc_linter/src/tsgolint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,10 @@ fn should_skip_diagnostic(
path: &Path,
tsgolint_diagnostic: &TsGoLintRuleDiagnostic,
) -> bool {
let span = tsgolint_diagnostic.span;
let span = tsgolint_diagnostic
.labeled_ranges
.first()
.map_or(tsgolint_diagnostic.span, |range| Span::new(range.range.pos, range.range.end));

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