]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/yoda.js
2 * @fileoverview Tests for yoda rule.
3 * @author Raphael Pigulla
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
11 const rule
= require("../../../lib/rules/yoda"),
12 { RuleTester
} = require("../../../lib/rule-tester");
14 //------------------------------------------------------------------------------
16 //------------------------------------------------------------------------------
18 const ruleTester
= new RuleTester();
20 ruleTester
.run("yoda", rule
, {
24 { code
: 'if (value === "red") {}', options
: ["never"] },
25 { code
: "if (value === value) {}", options
: ["never"] },
26 { code
: "if (value != 5) {}", options
: ["never"] },
27 { code
: "if (5 & foo) {}", options
: ["never"] },
28 { code
: "if (5 === 4) {}", options
: ["never"] },
30 code
: "if (value === `red`) {}",
32 parserOptions
: { ecmaVersion
: 2015 }
35 code
: "if (`red` === `red`) {}",
37 parserOptions
: { ecmaVersion
: 2015 }
40 code
: "if (`${foo}` === `red`) {}",
42 parserOptions
: { ecmaVersion
: 2015 }
45 code
: 'if (`${""}` === `red`) {}',
47 parserOptions
: { ecmaVersion
: 2015 }
50 code
: 'if (`${"red"}` === foo) {}',
52 parserOptions
: { ecmaVersion
: 2015 }
55 code
: "if (b > `a` && b > `a`) {}",
57 parserOptions
: { ecmaVersion
: 2015 }
60 code
: 'if (`b` > `a` && "b" > "a") {}',
62 parserOptions
: { ecmaVersion
: 2015 }
66 { code
: 'if ("blue" === value) {}', options
: ["always"] },
67 { code
: "if (value === value) {}", options
: ["always"] },
68 { code
: "if (4 != value) {}", options
: ["always"] },
69 { code
: "if (foo & 4) {}", options
: ["always"] },
70 { code
: "if (5 === 4) {}", options
: ["always"] },
72 code
: "if (`red` === value) {}",
74 parserOptions
: { ecmaVersion
: 2015 }
77 code
: "if (`red` === `red`) {}",
79 parserOptions
: { ecmaVersion
: 2015 }
82 code
: "if (`red` === `${foo}`) {}",
84 parserOptions
: { ecmaVersion
: 2015 }
87 code
: 'if (`red` === `${""}`) {}',
89 parserOptions
: { ecmaVersion
: 2015 }
92 code
: 'if (foo === `${"red"}`) {}',
94 parserOptions
: { ecmaVersion
: 2015 }
97 code
: "if (`a` > b && `a` > b) {}",
99 parserOptions
: { ecmaVersion
: 2015 }
102 code
: 'if (`b` > `a` && "b" > "a") {}',
104 parserOptions
: { ecmaVersion
: 2015 }
109 code
: 'if ("a" < x && x < MAX ) {}',
110 options
: ["never", { exceptRange
: true }]
113 code
: "if (1 < x && x < MAX ) {}",
114 options
: ["never", { exceptRange
: true }]
117 code
: "if ('a' < x && x < MAX ) {}",
118 options
: ["never", { exceptRange
: true }]
121 code
: "if (x < `x` || `x` <= x) {}",
122 options
: ["never", { exceptRange
: true }],
123 parserOptions
: { ecmaVersion
: 2015 }
126 code
: "if (0 < x && x <= 1) {}",
127 options
: ["never", { exceptRange
: true }]
130 code
: "if (0 <= x && x < 1) {}",
131 options
: ["always", { exceptRange
: true }]
134 code
: "if ('blue' < x.y && x.y < 'green') {}",
135 options
: ["never", { exceptRange
: true }]
138 code
: "if (0 < x[``] && x[``] < 100) {}",
139 options
: ["never", { exceptRange
: true }],
140 parserOptions
: { ecmaVersion
: 2015 }
143 code
: "if (0 < x[''] && x[``] < 100) {}",
144 options
: ["never", { exceptRange
: true }],
145 parserOptions
: { ecmaVersion
: 2015 }
149 "if (a < 4 || (b[c[0]].d['e'] < 0 || 1 <= b[c[0]].d['e'])) {}",
150 options
: ["never", { exceptRange
: true }]
153 code
: "if (0 <= x['y'] && x['y'] <= 100) {}",
154 options
: ["never", { exceptRange
: true }]
157 code
: "if (a < 0 && (0 < b && b < 1)) {}",
158 options
: ["never", { exceptRange
: true }]
161 code
: "if ((0 < a && a < 1) && b < 0) {}",
162 options
: ["never", { exceptRange
: true }]
165 code
: "if (-1 < x && x < 0) {}",
166 options
: ["never", { exceptRange
: true }]
169 code
: "if (0 <= this.prop && this.prop <= 1) {}",
170 options
: ["never", { exceptRange
: true }]
173 code
: "if (0 <= index && index < list.length) {}",
174 options
: ["never", { exceptRange
: true }]
177 code
: "if (ZERO <= index && index < 100) {}",
178 options
: ["never", { exceptRange
: true }]
181 code
: "if (value <= MIN || 10 < value) {}",
182 options
: ["never", { exceptRange
: true }]
185 code
: "if (value <= 0 || MAX < value) {}",
186 options
: ["never", { exceptRange
: true }]
189 code
: 'if (0 <= a.b && a["b"] <= 100) {}',
190 options
: ["never", { exceptRange
: true }]
193 code
: "if (0 <= a.b && a[`b`] <= 100) {}",
194 options
: ["never", { exceptRange
: true }],
195 parserOptions
: { ecmaVersion
: 2015 }
198 code
: "if (-1n < x && x <= 1n) {}",
199 options
: ["never", { exceptRange
: true }],
200 parserOptions
: { ecmaVersion
: 2020 }
203 code
: "if (-1n <= x && x < 1n) {}",
204 options
: ["always", { exceptRange
: true }],
205 parserOptions
: { ecmaVersion
: 2020 }
208 code
: "if (x < `1` || `1` < x) {}",
209 options
: ["always", { exceptRange
: true }],
210 parserOptions
: { ecmaVersion
: 2020 }
213 code
: "if (1 <= a['/(?<zero>0)/'] && a[/(?<zero>0)/] <= 100) {}",
214 options
: ["never", { exceptRange
: true }],
215 parserOptions
: { ecmaVersion
: 2018 }
218 code
: "if (x <= `bar` || `foo` < x) {}",
219 options
: ["always", { exceptRange
: true }],
220 parserOptions
: { ecmaVersion
: 2015 }
223 code
: "if ('a' < x && x < MAX ) {}",
224 options
: ["always", { exceptRange
: true }],
225 parserOptions
: { ecmaVersion
: 2015 }
228 code
: "if ('a' < x && x < MAX ) {}",
230 parserOptions
: { ecmaVersion
: 2015 }
233 code
: "if (MIN < x && x < 'a' ) {}",
234 options
: ["never", { exceptRange
: true }],
235 parserOptions
: { ecmaVersion
: 2015 }
238 code
: "if (MIN < x && x < 'a' ) {}",
240 parserOptions
: { ecmaVersion
: 2015 }
243 code
: "if (`blue` < x.y && x.y < `green`) {}",
244 options
: ["never", { exceptRange
: true }],
245 parserOptions
: { ecmaVersion
: 2015 }
248 code
: "if (0 <= x[`y`] && x[`y`] <= 100) {}",
249 options
: ["never", { exceptRange
: true }],
250 parserOptions
: { ecmaVersion
: 2015 }
253 code
: 'if (0 <= x[`y`] && x["y"] <= 100) {}',
254 options
: ["never", { exceptRange
: true }],
255 parserOptions
: { ecmaVersion
: 2015 }
258 code
: "if ('a' <= x && x < 'b') {}",
259 options
: ["never", { exceptRange
: true }]
262 code
: "if (x < -1n || 1n <= x) {}",
263 options
: ["never", { exceptRange
: true }],
264 parserOptions
: { ecmaVersion
: 2020 }
267 code
: "if (x < -1n || 1n <= x) {}",
268 options
: ["always", { exceptRange
: true }],
269 parserOptions
: { ecmaVersion
: 2020 }
272 code
: "if (1 < a && a <= 2) {}",
273 options
: ["never", { exceptRange
: true }]
276 code
: "if (x < -1 || 1 < x) {}",
277 options
: ["never", { exceptRange
: true }]
280 code
: "if (x <= 'bar' || 'foo' < x) {}",
281 options
: ["always", { exceptRange
: true }]
284 code
: "if (x < 0 || 1 <= x) {}",
285 options
: ["never", { exceptRange
: true }]
288 code
: "if('a' <= x && x < MAX) {}",
289 options
: ["never", { exceptRange
: true }]
294 code
: "if (0 < x && x <= 1) {}",
295 options
: ["never", { onlyEquality
: true }]
298 code
: "if (x !== 'foo' && 'foo' !== x) {}",
299 options
: ["never", { onlyEquality
: true }]
302 code
: "if (x < 2 && x !== -3) {}",
303 options
: ["always", { onlyEquality
: true }]
306 code
: "if (x !== `foo` && `foo` !== x) {}",
307 options
: ["never", { onlyEquality
: true }],
308 parserOptions
: { ecmaVersion
: 2015 }
311 code
: "if (x < `2` && x !== `-3`) {}",
312 options
: ["always", { onlyEquality
: true }],
313 parserOptions
: { ecmaVersion
: 2015 }
318 code
: "if (x <= 'foo' || 'bar' < x) {}",
319 output
: "if ('foo' >= x || 'bar' < x) {}",
320 options
: ["always", { exceptRange
: true }],
323 messageId
: "expected",
324 data
: { expectedSide
: "left", operator
: "<=" },
325 type
: "BinaryExpression"
330 code
: 'if ("red" == value) {}',
331 output
: 'if (value == "red") {}',
335 messageId
: "expected",
336 data
: { expectedSide
: "right", operator
: "==" },
337 type
: "BinaryExpression"
342 code
: "if (true === value) {}",
343 output
: "if (value === true) {}",
347 messageId
: "expected",
348 data
: { expectedSide
: "right", operator
: "===" },
349 type
: "BinaryExpression"
354 code
: "if (5 != value) {}",
355 output
: "if (value != 5) {}",
359 messageId
: "expected",
360 data
: { expectedSide
: "right", operator
: "!=" },
361 type
: "BinaryExpression"
366 code
: "if (5n != value) {}",
367 output
: "if (value != 5n) {}",
369 parserOptions
: { ecmaVersion
: 2020 },
372 messageId
: "expected",
373 data
: { expectedSide
: "right", operator
: "!=" },
374 type
: "BinaryExpression"
379 code
: "if (null !== value) {}",
380 output
: "if (value !== null) {}",
384 messageId
: "expected",
385 data
: { expectedSide
: "right", operator
: "!==" },
386 type
: "BinaryExpression"
391 code
: 'if ("red" <= value) {}',
392 output
: 'if (value >= "red") {}',
396 messageId
: "expected",
397 data
: { expectedSide
: "right", operator
: "<=" },
398 type
: "BinaryExpression"
403 code
: "if (`red` <= value) {}",
404 output
: "if (value >= `red`) {}",
406 parserOptions
: { ecmaVersion
: 2015 },
409 messageId
: "expected",
410 data
: { expectedSide
: "right", operator
: "<=" },
411 type
: "BinaryExpression"
416 code
: "if (`red` <= `${foo}`) {}",
417 output
: "if (`${foo}` >= `red`) {}",
419 parserOptions
: { ecmaVersion
: 2015 },
422 messageId
: "expected",
423 data
: { expectedSide
: "right", operator
: "<=" },
424 type
: "BinaryExpression"
429 code
: 'if (`red` <= `${"red"}`) {}',
430 output
: 'if (`${"red"}` >= `red`) {}',
432 parserOptions
: { ecmaVersion
: 2015 },
435 messageId
: "expected",
436 data
: { expectedSide
: "right", operator
: "<=" },
437 type
: "BinaryExpression"
442 code
: "if (true >= value) {}",
443 output
: "if (value <= true) {}",
447 messageId
: "expected",
448 data
: { expectedSide
: "right", operator
: ">=" },
449 type
: "BinaryExpression"
454 code
: "var foo = (5 < value) ? true : false",
455 output
: "var foo = (value > 5) ? true : false",
459 messageId
: "expected",
460 data
: { expectedSide
: "right", operator
: "<" },
461 type
: "BinaryExpression"
466 code
: "function foo() { return (null > value); }",
467 output
: "function foo() { return (value < null); }",
471 messageId
: "expected",
472 data
: { expectedSide
: "right", operator
: ">" },
473 type
: "BinaryExpression"
478 code
: "if (-1 < str.indexOf(substr)) {}",
479 output
: "if (str.indexOf(substr) > -1) {}",
483 messageId
: "expected",
484 data
: { expectedSide
: "right", operator
: "<" },
485 type
: "BinaryExpression"
490 code
: 'if (value == "red") {}',
491 output
: 'if ("red" == value) {}',
495 messageId
: "expected",
496 data
: { expectedSide
: "left", operator
: "==" },
497 type
: "BinaryExpression"
502 code
: "if (value == `red`) {}",
503 output
: "if (`red` == value) {}",
505 parserOptions
: { ecmaVersion
: 2015 },
508 messageId
: "expected",
509 data
: { expectedSide
: "left", operator
: "==" },
510 type
: "BinaryExpression"
515 code
: "if (value === true) {}",
516 output
: "if (true === value) {}",
520 messageId
: "expected",
521 data
: { expectedSide
: "left", operator
: "===" },
522 type
: "BinaryExpression"
527 code
: "if (value === 5n) {}",
528 output
: "if (5n === value) {}",
530 parserOptions
: { ecmaVersion
: 2020 },
533 messageId
: "expected",
534 data
: { expectedSide
: "left", operator
: "===" },
535 type
: "BinaryExpression"
540 code
: 'if (`${"red"}` <= `red`) {}',
541 output
: 'if (`red` >= `${"red"}`) {}',
543 parserOptions
: { ecmaVersion
: 2015 },
546 messageId
: "expected",
547 data
: { expectedSide
: "left", operator
: "<=" },
548 type
: "BinaryExpression"
553 code
: "if (a < 0 && 0 <= b && b < 1) {}",
554 output
: "if (a < 0 && b >= 0 && b < 1) {}",
555 options
: ["never", { exceptRange
: true }],
558 messageId
: "expected",
559 data
: { expectedSide
: "right", operator
: "<=" },
560 type
: "BinaryExpression"
565 code
: "if (0 <= a && a < 1 && b < 1) {}",
566 output
: "if (a >= 0 && a < 1 && b < 1) {}",
567 options
: ["never", { exceptRange
: true }],
570 messageId
: "expected",
571 data
: { expectedSide
: "right", operator
: "<=" },
572 type
: "BinaryExpression"
577 code
: "if (1 < a && a < 0) {}",
578 output
: "if (a > 1 && a < 0) {}",
579 options
: ["never", { exceptRange
: true }],
582 messageId
: "expected",
583 data
: { expectedSide
: "right", operator
: "<" },
584 type
: "BinaryExpression"
589 code
: "0 < a && a < 1",
590 output
: "a > 0 && a < 1",
591 options
: ["never", { exceptRange
: true }],
594 messageId
: "expected",
595 data
: { expectedSide
: "right", operator
: "<" },
596 type
: "BinaryExpression"
601 code
: "var a = b < 0 || 1 <= b;",
602 output
: "var a = b < 0 || b >= 1;",
603 options
: ["never", { exceptRange
: true }],
606 messageId
: "expected",
607 data
: { expectedSide
: "right", operator
: "<=" },
608 type
: "BinaryExpression"
613 code
: "if (0 <= x && x < -1) {}",
614 output
: "if (x >= 0 && x < -1) {}",
615 options
: ["never", { exceptRange
: true }],
618 messageId
: "expected",
619 data
: { expectedSide
: "right", operator
: "<=" },
620 type
: "BinaryExpression"
625 code
: "var a = (b < 0 && 0 <= b);",
626 output
: "var a = (0 > b && 0 <= b);",
627 options
: ["always", { exceptRange
: true }],
630 messageId
: "expected",
631 data
: { expectedSide
: "left", operator
: "<" },
632 type
: "BinaryExpression"
637 code
: "var a = (b < `0` && `0` <= b);",
638 output
: "var a = (`0` > b && `0` <= b);",
639 options
: ["always", { exceptRange
: true }],
640 parserOptions
: { ecmaVersion
: 2015 },
643 messageId
: "expected",
644 data
: { expectedSide
: "left", operator
: "<" },
645 type
: "BinaryExpression"
650 code
: "if (`green` < x.y && x.y < `blue`) {}",
651 output
: "if (x.y > `green` && x.y < `blue`) {}",
652 options
: ["never", { exceptRange
: true }],
653 parserOptions
: { ecmaVersion
: 2015 },
656 messageId
: "expected",
657 data
: { expectedSide
: "right", operator
: "<" },
658 type
: "BinaryExpression"
663 code
: "if (0 <= a[b] && a['b'] < 1) {}",
664 output
: "if (a[b] >= 0 && a['b'] < 1) {}",
665 options
: ["never", { exceptRange
: true }],
668 messageId
: "expected",
669 data
: { expectedSide
: "right", operator
: "<=" },
670 type
: "BinaryExpression"
675 code
: "if (0 <= a[b] && a[`b`] < 1) {}",
676 output
: "if (a[b] >= 0 && a[`b`] < 1) {}",
677 options
: ["never", { exceptRange
: true }],
678 parserOptions
: { ecmaVersion
: 2015 },
681 messageId
: "expected",
682 data
: { expectedSide
: "right", operator
: "<=" },
683 type
: "BinaryExpression"
688 code
: "if (`0` <= a[b] && a[`b`] < `1`) {}",
689 output
: "if (a[b] >= `0` && a[`b`] < `1`) {}",
690 options
: ["never", { exceptRange
: true }],
691 parserOptions
: { ecmaVersion
: 2015 },
694 messageId
: "expected",
695 data
: { expectedSide
: "right", operator
: "<=" },
696 type
: "BinaryExpression"
701 code
: "if (0 <= a[b] && a.b < 1) {}",
702 output
: "if (a[b] >= 0 && a.b < 1) {}",
703 options
: ["never", { exceptRange
: true }],
706 messageId
: "expected",
707 data
: { expectedSide
: "right", operator
: "<=" },
708 type
: "BinaryExpression"
713 code
: "if (0 <= a[''] && a.b < 1) {}",
714 output
: "if (a[''] >= 0 && a.b < 1) {}",
715 options
: ["never", { exceptRange
: true }],
718 messageId
: "expected",
719 data
: { expectedSide
: "right", operator
: "<=" },
720 type
: "BinaryExpression"
725 code
: "if (0 <= a[''] && a[' '] < 1) {}",
726 output
: "if (a[''] >= 0 && a[' '] < 1) {}",
727 options
: ["never", { exceptRange
: true }],
730 messageId
: "expected",
731 data
: { expectedSide
: "right", operator
: "<=" },
732 type
: "BinaryExpression"
737 code
: "if (0 <= a[''] && a[null] < 1) {}",
738 output
: "if (a[''] >= 0 && a[null] < 1) {}",
739 options
: ["never", { exceptRange
: true }],
742 messageId
: "expected",
743 data
: { expectedSide
: "right", operator
: "<=" },
744 type
: "BinaryExpression"
749 code
: "if (0 <= a[``] && a[null] < 1) {}",
750 output
: "if (a[``] >= 0 && a[null] < 1) {}",
751 options
: ["never", { exceptRange
: true }],
752 parserOptions
: { ecmaVersion
: 2015 },
755 messageId
: "expected",
756 data
: { expectedSide
: "right", operator
: "<=" },
757 type
: "BinaryExpression"
762 code
: "if (0 <= a[''] && a[b] < 1) {}",
763 output
: "if (a[''] >= 0 && a[b] < 1) {}",
764 options
: ["never", { exceptRange
: true }],
767 messageId
: "expected",
768 data
: { expectedSide
: "right", operator
: "<=" },
769 type
: "BinaryExpression"
774 code
: "if (0 <= a[''] && a[b()] < 1) {}",
775 output
: "if (a[''] >= 0 && a[b()] < 1) {}",
776 options
: ["never", { exceptRange
: true }],
779 messageId
: "expected",
780 data
: { expectedSide
: "right", operator
: "<=" },
781 type
: "BinaryExpression"
786 code
: "if (0 <= a[``] && a[b()] < 1) {}",
787 output
: "if (a[``] >= 0 && a[b()] < 1) {}",
788 options
: ["never", { exceptRange
: true }],
789 parserOptions
: { ecmaVersion
: 2015 },
792 messageId
: "expected",
793 data
: { expectedSide
: "right", operator
: "<=" },
794 type
: "BinaryExpression"
799 code
: "if (0 <= a[b()] && a[b()] < 1) {}",
800 output
: "if (a[b()] >= 0 && a[b()] < 1) {}",
801 options
: ["never", { exceptRange
: true }],
804 messageId
: "expected",
805 data
: { expectedSide
: "right", operator
: "<=" },
806 type
: "BinaryExpression"
811 code
: "if (0 <= a.null && a[/(?<zero>0)/] <= 1) {}",
812 output
: "if (a.null >= 0 && a[/(?<zero>0)/] <= 1) {}",
813 options
: ["never", { exceptRange
: true }],
814 parserOptions
: { ecmaVersion
: 2018 },
817 messageId
: "expected",
818 data
: { expectedSide
: "right", operator
: "<=" },
819 type
: "BinaryExpression"
824 code
: "if (3 == a) {}",
825 output
: "if (a == 3) {}",
826 options
: ["never", { onlyEquality
: true }],
829 messageId
: "expected",
830 data
: { expectedSide
: "right", operator
: "==" },
831 type
: "BinaryExpression"
836 code
: "foo(3 === a);",
837 output
: "foo(a === 3);",
838 options
: ["never", { onlyEquality
: true }],
841 messageId
: "expected",
842 data
: { expectedSide
: "right", operator
: "===" },
843 type
: "BinaryExpression"
848 code
: "foo(a === 3);",
849 output
: "foo(3 === a);",
850 options
: ["always", { onlyEquality
: true }],
853 messageId
: "expected",
854 data
: { expectedSide
: "left", operator
: "===" },
855 type
: "BinaryExpression"
860 code
: "foo(a === `3`);",
861 output
: "foo(`3` === a);",
862 options
: ["always", { onlyEquality
: true }],
863 parserOptions
: { ecmaVersion
: 2015 },
866 messageId
: "expected",
867 data
: { expectedSide
: "left", operator
: "===" },
868 type
: "BinaryExpression"
873 code
: "if (0 <= x && x < 1) {}",
874 output
: "if (x >= 0 && x < 1) {}",
877 messageId
: "expected",
878 data
: { expectedSide
: "right", operator
: "<=" },
879 type
: "BinaryExpression"
884 code
: "if ( /* a */ 0 /* b */ < /* c */ foo /* d */ ) {}",
885 output
: "if ( /* a */ foo /* b */ > /* c */ 0 /* d */ ) {}",
889 messageId
: "expected",
890 data
: { expectedSide
: "right", operator
: "<" },
891 type
: "BinaryExpression"
896 code
: "if ( /* a */ foo /* b */ > /* c */ 0 /* d */ ) {}",
897 output
: "if ( /* a */ 0 /* b */ < /* c */ foo /* d */ ) {}",
901 messageId
: "expected",
902 data
: { expectedSide
: "left", operator
: ">" },
903 type
: "BinaryExpression"
908 code
: "if (foo()===1) {}",
909 output
: "if (1===foo()) {}",
913 messageId
: "expected",
914 data
: { expectedSide
: "left", operator
: "===" },
915 type
: "BinaryExpression"
920 code
: "if (foo() === 1) {}",
921 output
: "if (1 === foo()) {}",
925 messageId
: "expected",
926 data
: { expectedSide
: "left", operator
: "===" },
927 type
: "BinaryExpression"
932 // https://github.com/eslint/eslint/issues/7326
934 code
: "while (0 === (a));",
935 output
: "while ((a) === 0);",
939 messageId
: "expected",
940 data
: { expectedSide
: "right", operator
: "===" },
941 type
: "BinaryExpression"
946 code
: "while (0 === (a = b));",
947 output
: "while ((a = b) === 0);",
951 messageId
: "expected",
952 data
: { expectedSide
: "right", operator
: "===" },
953 type
: "BinaryExpression"
958 code
: "while ((a) === 0);",
959 output
: "while (0 === (a));",
963 messageId
: "expected",
964 data
: { expectedSide
: "left", operator
: "===" },
965 type
: "BinaryExpression"
970 code
: "while ((a = b) === 0);",
971 output
: "while (0 === (a = b));",
975 messageId
: "expected",
976 data
: { expectedSide
: "left", operator
: "===" },
977 type
: "BinaryExpression"
982 code
: "if (((((((((((foo)))))))))) === ((((((5)))))));",
983 output
: "if (((((((5)))))) === ((((((((((foo)))))))))));",
987 messageId
: "expected",
988 data
: { expectedSide
: "left", operator
: "===" },
989 type
: "BinaryExpression"
994 // Adjacent tokens tests
996 code
: "function *foo() { yield(1) < a }",
997 output
: "function *foo() { yield a > (1) }",
999 parserOptions
: { ecmaVersion
: 2015 },
1002 messageId
: "expected",
1003 data
: { expectedSide
: "right", operator
: "<" },
1004 type
: "BinaryExpression"
1009 code
: "function *foo() { yield((1)) < a }",
1010 output
: "function *foo() { yield a > ((1)) }",
1012 parserOptions
: { ecmaVersion
: 2015 },
1015 messageId
: "expected",
1016 data
: { expectedSide
: "right", operator
: "<" },
1017 type
: "BinaryExpression"
1022 code
: "function *foo() { yield 1 < a }",
1023 output
: "function *foo() { yield a > 1 }",
1025 parserOptions
: { ecmaVersion
: 2015 },
1028 messageId
: "expected",
1029 data
: { expectedSide
: "right", operator
: "<" },
1030 type
: "BinaryExpression"
1035 code
: "function *foo() { yield/**/1 < a }",
1036 output
: "function *foo() { yield/**/a > 1 }",
1038 parserOptions
: { ecmaVersion
: 2015 },
1041 messageId
: "expected",
1042 data
: { expectedSide
: "right", operator
: "<" },
1043 type
: "BinaryExpression"
1048 code
: "function *foo() { yield(1) < ++a }",
1049 output
: "function *foo() { yield++a > (1) }",
1051 parserOptions
: { ecmaVersion
: 2015 },
1054 messageId
: "expected",
1055 data
: { expectedSide
: "right", operator
: "<" },
1056 type
: "BinaryExpression"
1061 code
: "function *foo() { yield(1) < (a) }",
1062 output
: "function *foo() { yield(a) > (1) }",
1064 parserOptions
: { ecmaVersion
: 2015 },
1067 messageId
: "expected",
1068 data
: { expectedSide
: "right", operator
: "<" },
1069 type
: "BinaryExpression"
1079 messageId
: "expected",
1080 data
: { expectedSide
: "right", operator
: "<" },
1081 type
: "BinaryExpression"
1086 code
: "function *foo() { yield++a < 1 }",
1087 output
: "function *foo() { yield 1 > ++a }",
1088 options
: ["always"],
1089 parserOptions
: { ecmaVersion
: 2015 },
1092 messageId
: "expected",
1093 data
: { expectedSide
: "left", operator
: "<" },
1094 type
: "BinaryExpression"
1099 code
: "function *foo() { yield(a) < 1 }",
1100 output
: "function *foo() { yield 1 > (a) }",
1101 options
: ["always"],
1102 parserOptions
: { ecmaVersion
: 2015 },
1105 messageId
: "expected",
1106 data
: { expectedSide
: "left", operator
: "<" },
1107 type
: "BinaryExpression"
1112 code
: "function *foo() { yield a < 1 }",
1113 output
: "function *foo() { yield 1 > a }",
1114 options
: ["always"],
1115 parserOptions
: { ecmaVersion
: 2015 },
1118 messageId
: "expected",
1119 data
: { expectedSide
: "left", operator
: "<" },
1120 type
: "BinaryExpression"
1125 code
: "function *foo() { yield/**/a < 1 }",
1126 output
: "function *foo() { yield/**/1 > a }",
1127 options
: ["always"],
1128 parserOptions
: { ecmaVersion
: 2015 },
1131 messageId
: "expected",
1132 data
: { expectedSide
: "left", operator
: "<" },
1133 type
: "BinaryExpression"
1138 code
: "function *foo() { yield++a < (1) }",
1139 output
: "function *foo() { yield(1) > ++a }",
1140 options
: ["always"],
1141 parserOptions
: { ecmaVersion
: 2015 },
1144 messageId
: "expected",
1145 data
: { expectedSide
: "left", operator
: "<" },
1146 type
: "BinaryExpression"
1153 options
: ["always"],
1156 messageId
: "expected",
1157 data
: { expectedSide
: "left", operator
: "<" },
1158 type
: "BinaryExpression"
1163 code
: "if (`green` < x.y && x.y < `blue`) {}",
1164 output
: "if (`green` < x.y && `blue` > x.y) {}",
1165 options
: ["always", { exceptRange
: true }],
1166 parserOptions
: { ecmaVersion
: 2015 },
1169 messageId
: "expected",
1170 data
: { expectedSide
: "left", operator
: "<" },
1171 type
: "BinaryExpression"
1176 code
: "if('a' <= x && x < 'b') {}",
1177 output
: "if('a' <= x && 'b' > x) {}",
1178 options
: ["always"],
1181 messageId
: "expected",
1182 data
: { expectedSide
: "left", operator
: "<" },
1183 type
: "BinaryExpression"
1188 code
: "if ('b' <= x && x < 'a') {}",
1189 output
: "if (x >= 'b' && x < 'a') {}",
1190 options
: ["never", { exceptRange
: true }],
1193 messageId
: "expected",
1194 data
: { expectedSide
: "right", operator
: "<=" },
1195 type
: "BinaryExpression"
1200 code
: "if('a' <= x && x < 1) {}",
1201 output
: "if(x >= 'a' && x < 1) {}",
1202 options
: ["never", { exceptRange
: true }],
1205 messageId
: "expected",
1206 data
: { expectedSide
: "right", operator
: "<=" },
1207 type
: "BinaryExpression"
1212 code
: "if (0 < a && b < max) {}",
1213 output
: "if (a > 0 && b < max) {}",
1214 options
: ["never", { exceptRange
: true }],
1217 messageId
: "expected",
1218 data
: { expectedSide
: "right", operator
: "<" },
1219 type
: "BinaryExpression"