Skip to content

Commit 304d532

Browse files
committed
chore: Add tests for no-constant-binary-expression
1 parent d8f9a86 commit 304d532

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Diff for: test/no-constant-binary-expression.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*eslint-disable no-undef,no-unused-vars*/
2+
3+
// Incorrect
4+
const value1 = +x == null; // eslint-disable-line no-constant-binary-expression
5+
6+
const value2 = condition ? x : {} || DEFAULT; // eslint-disable-line no-constant-binary-expression
7+
8+
const value3 = !foo == null; // eslint-disable-line no-constant-binary-expression
9+
10+
const value4 = new Boolean(foo) === true; // eslint-disable-line no-constant-binary-expression
11+
12+
const objIsEmpty = someObj === {}; // eslint-disable-line no-constant-binary-expression
13+
14+
const arrIsEmpty = someArr === []; // eslint-disable-line no-constant-binary-expression
15+
16+
const shortCircuit1 = condition1 && false && condition2; // eslint-disable-line no-constant-binary-expression
17+
18+
const shortCircuit2 = condition1 || true || condition2; // eslint-disable-line no-constant-binary-expression
19+
20+
// Correct
21+
const value11 = x == null;
22+
23+
const value21 = (condition ? x : {}) || DEFAULT;
24+
25+
const value31 = !(foo == null);
26+
27+
const value41 = Boolean(foo) === true;
28+
29+
const objIsEmpty1 = Object.keys(someObj).length === 0;
30+
31+
const arrIsEmpty1 = someArr.length === 0;

0 commit comments

Comments
 (0)