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
1 change: 1 addition & 0 deletions apps/oxlint/fixtures/tsgolint/.oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"typescript/restrict-plus-operands": "error",
"typescript/restrict-template-expressions": "error",
"typescript/return-await": "error",
"typescript/strict-boolean-expressions": "error",
"typescript/switch-exhaustiveness-check": "error",
"typescript/unbound-method": "error",
"typescript/use-unknown-in-catch-callback-variable": "error",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Examples of incorrect code for strict-boolean-expressions rule

// Non-boolean values in conditions
const str = 'hello';
if (str) { // string is not a boolean
console.log('string');
}

const num = 42;
if (num) { // number is not a boolean
console.log('number');
}

const obj = { foo: 'bar' };
if (obj) { // object is not a boolean
console.log('object');
}

// Nullable booleans
declare const maybeBool: boolean | null;
if (maybeBool) { // nullable boolean
console.log('maybe');
}

// Undefined checks
declare const maybeString: string | undefined;
if (maybeString) { // should explicitly check !== undefined
console.log(maybeString);
}

// Logical operators with non-booleans
const result1 = str && num;
const result2 = obj || num;

// While loops with non-boolean
while (num) {
console.log('loop');
break;
}

// Do-while with non-boolean
do {
console.log('do');
} while (str);

// For loop with non-boolean
for (let i = 0; i; i++) {
console.log('for');
}

// Ternary with non-boolean
const ternary = str ? 'yes' : 'no';

// Logical NOT on non-boolean
const negated = !str;

// Mixed types in logical expressions
declare const mixed: string | number;
if (mixed) {
console.log('mixed');
}

// any type (should allow or warn depending on config)
declare const anyValue: any;
if (anyValue) {
console.log('any');
}
3 changes: 1 addition & 2 deletions apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,8 +1276,7 @@ mod test {
#[test]
#[cfg(not(target_endian = "big"))]
fn test_tsgolint() {
// TODO: test with other rules as well once diagnostics are more stable
let args = &["--type-aware", "no-floating-promises"];
let args = &["--type-aware"];
Tester::new().with_cwd("fixtures/tsgolint".into()).test_and_snapshot(args);
}

Expand Down

This file was deleted.

Loading
Loading