test: ts/useSimplifiedBooleanExpression
MODIFY
internal/compiler/lint/rules/js/useSimplifiedLogicalExpression.test.rjson
internal/compiler/lint/rules/js/useSimplifiedLogicalExpression.test.rjson
@@ -18,4 +18,10 @@ invalid: [
const r = (!boolExpr1) || (!boolExpr2);
"
]
-valid: []
+valid: [
+ "
+ const boolExpr1 = true;
+ const boolExpr2 = false;
+ const r = !(boolExpr1 && boolExpr2);
+ "
+]

ADD
internal/compiler/lint/rules/ts/useSimplifiedBooleanExpression.test.ts
+import {test} from "rome";
+import {testLint} from "../../utils/testing";
+
+test(
+ "ts use simplified boolean expression",
+ async (t) => {
+ await testLint(
+ t,
+ {
+ invalid: [
+ "function foo(x: boolean) { return !!x; }",
+ "function foo(x: boolean) { return x === true; }",
+ "function foo(x: boolean) { return false === x; }",
+ "function foo(x: boolean, y: boolean) { return (x || y) === true }",
+ ],
+ valid: [
+ "function foo(x?: boolean) { return !!x; }",
+ "function foo(x: boolean | number) { return x === true; }",
+ "function foo(x: boolean | undefined) { return false === x; }",
+ ],
+ filename: "file.ts",
+ category: "lint/ts/useSimplifiedBooleanExpression",
+ },
+ );
+ },
+);

test: ts/useSimplifiedBooleanExpression