Repository: eslint/eslint
File: tests/lib/rules/no-constant-condition.js (JavaScript)

Code before:
        {
            code: "if(1n && a){};",
            languageOptions: { ecmaVersion: 11 }
        },

        // #12225
        "if ('' + [y] === '' + [ty]) {}",
        "if ('a' === '' + [ty]) {}",
        "if ('' + [y, m, d] === 'a') {}",
        "if ('' + [y, 'm'] === '' + [ty, 'tm']) {}",
        "if ('' + [y, 'm'] === '' + ['ty']) {}",
        "if ([,] in\n\n($2))\n ;\nelse\n ;",
        "if ([...x]+'' === 'y'){}",

        // { checkLoops: false }
        { code: "while(true);", options: [{ checkLoops: false }] },
        { code: "for(;true;);", options: [{ checkLoops: false }] },
        { code: "do{}while(true)", options: [{ checkLoops: false }] },

        // { checkLoops: "none" }
        { code: "while(true);", options: [{ checkLoops: "none" }] },
        { code: "for(;true;);", options: [{ checkLoops: "none" }] },
        { code: "do{}while(true)", options: [{ checkLoops: "none" }] },

        // { checkloops: "allExceptWhileTrue" }
        { code: "while(true);", options: [{ checkLoops: "allExceptWhileTrue" }] },

        // { checkloops: "all" }
        { code: "while(a == b);", options: [{ checkLoops: "all" }] },
        { code: "do{ }while(x);", options: [{ checkLoops: "all" }] },
        { code: "for (let x = 0; x <= 10; x++) {};", options: [{ checkLoops: "all" }] },

        "function* foo(){while(true){yield 'foo';}}",
        "function* foo(){for(;true;){yield 'foo';}}",
        "function* foo(){do{yield 'foo';}while(true)}",
        "function* foo(){while (true) { while(true) {yield;}}}",
        "function* foo() {for (; yield; ) {}}",
        "function* foo() {for (; ; yield) {}}",
        "function* foo() {while (true) {function* foo() {yield;}yield;}}",
        "function* foo() { for (let x = yield; x < 10; x++) {yield;}yield;}",
        "function* foo() { for (let x = yield; ; x++) { yield; }}",
        "if (new Number(x) + 1 === 2) {}",

        // #15467
        "if([a]==[b]) {}",
        "if (+[...a]) {}",
        "if (+[...[...a]]) {}",
        "if (`${[...a]}`) {}",
        "if (`${[a]}`) {}",
        "if (+[a]) {}",
        "if (0 - [a]) {}",

Review comment (suggestion):
as it's the new default, good to have a test like:
```js
{ code: "while(true);"}
```

Code after:
        {
            code: "if(1n && a){};",
            languageOptions: { ecmaVersion: 11 }
        },

        // #12225
        "if ('' + [y] === '' + [ty]) {}",
        "if ('a' === '' + [ty]) {}",
        "if ('' + [y, m, d] === 'a') {}",
        "if ('' + [y, 'm'] === '' + [ty, 'tm']) {}",
        "if ('' + [y, 'm'] === '' + ['ty']) {}",
        "if ([,] in\n\n($2))\n ;\nelse\n ;",
        "if ([...x]+'' === 'y'){}",

        // { checkLoops: false }
        { code: "while(true);", options: [{ checkLoops: false }] },
        { code: "for(;true;);", options: [{ checkLoops: false }] },
        { code: "do{}while(true)", options: [{ checkLoops: false }] },

        // { checkLoops: "none" }
        { code: "while(true);", options: [{ checkLoops: "none" }] },
        { code: "for(;true;);", options: [{ checkLoops: "none" }] },
        { code: "do{}while(true)", options: [{ checkLoops: "none" }] },

        // { checkloops: "allExceptWhileTrue" }
        { code: "while(true);", options: [{ checkLoops: "allExceptWhileTrue" }] },
        "while(true);",

        // { checkloops: "all" }
        { code: "while(a == b);", options: [{ checkLoops: "all" }] },
        { code: "do{ }while(x);", options: [{ checkLoops: "all" }] },
        { code: "for (let x = 0; x <= 10; x++) {};", options: [{ checkLoops: "all" }] },

        "function* foo(){while(true){yield 'foo';}}",
        "function* foo(){for(;true;){yield 'foo';}}",
        "function* foo(){do{yield 'foo';}while(true)}",
        "function* foo(){while (true) { while(true) {yield;}}}",
        "function* foo() {for (; yield; ) {}}",
        "function* foo() {for (; ; yield) {}}",
        "function* foo() {while (true) {function* foo() {yield;}yield;}}",
        "function* foo() { for (let x = yield; x < 10; x++) {yield;}yield;}",
        "function* foo() { for (let x = yield; ; x++) { yield; }}",
        "if (new Number(x) + 1 === 2) {}",

        // #15467
        "if([a]==[b]) {}",
        "if (+[...a]) {}",
        "if (+[...[...a]]) {}",
        "if (`${[...a]}`) {}",
        "if (`${[a]}`) {}",
        "if (+[a]) {}",