From 9fd5b821538da6931e953782db60635bad92bf8e Mon Sep 17 00:00:00 2001 From: "ryan.waskiewicz" Date: Mon, 7 May 2018 19:36:12 -0400 Subject: [PATCH] [docs] Fix prefer-while docs - Updated docs to make sense semantically (use vars that should exist in the scope of each for-loop) - Updated tests with same issue --- src/rules/code-examples/preferWhile.examples.ts | 12 ++++++------ test/rules/prefer-while/test.ts.fix | 12 ++++++------ test/rules/prefer-while/test.ts.lint | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/rules/code-examples/preferWhile.examples.ts b/src/rules/code-examples/preferWhile.examples.ts index 30cf27c9ebb..4d7bea48e05 100644 --- a/src/rules/code-examples/preferWhile.examples.ts +++ b/src/rules/code-examples/preferWhile.examples.ts @@ -25,12 +25,12 @@ export const codeExamples = [ "rules": { "prefer-while": true } `, pass: Lint.Utils.dedent` - for(let x = 1; x < 10; x++) { - console.log(x); + for(let i = 1; i < 10; i++) { + console.log(i); } - for (let i = 0; i < 10; x+=1) { - console.log(x); + for (let i = 0; i < 10; i+=1) { + console.log(i); } for (let i = 0; i < 10;) { @@ -39,11 +39,11 @@ export const codeExamples = [ `, fail: Lint.Utils.dedent` for(;;) { - console.log(x); + console.log('Hello World'); } for(;true===true;) { - console.log(x); + console.log('Hello World'); } `, }, diff --git a/test/rules/prefer-while/test.ts.fix b/test/rules/prefer-while/test.ts.fix index 43d120d1491..248cc3cc822 100644 --- a/test/rules/prefer-while/test.ts.fix +++ b/test/rules/prefer-while/test.ts.fix @@ -1,21 +1,21 @@ // for loops without an initializer, termination condition, and incrementor should be updated while (true) { - console.log(x); + console.log('Hello World'); } // for loops without an initializer and incrementor should be updated while (true===true) { - console.log(x); + console.log('Hello World'); } // for loops with an initializer, termination condition, and incrementor using '++' should remain untouched -for(let x = 1; x < 10; x++) { - console.log(x); +for (let i = 1; i < 10; i++) { + console.log(i); } // for loops with an initializer, termination condition, and incrementor using '+=' should remain untouched -for (let i = 0; i < 10; x+=1) { - console.log(x); +for (let i = 0; i < 10; i+=1) { + console.log(i); } // for loops with an initializer and termination condition should remain untouched diff --git a/test/rules/prefer-while/test.ts.lint b/test/rules/prefer-while/test.ts.lint index cc6c417132f..0b0cad78dd2 100644 --- a/test/rules/prefer-while/test.ts.lint +++ b/test/rules/prefer-while/test.ts.lint @@ -1,23 +1,23 @@ // for loops without an initializer, termination condition, and incrementor should be updated for(;;) { ~~~~~~~ [Prefer `while` loops instead of `for` loops without an initializer and incrementor.] - console.log(x); + console.log('Hello World'); } // for loops without an initializer and incrementor should be updated for(;true===true;) { ~~~~~~~~~~~~~~~~~~ [Prefer `while` loops instead of `for` loops without an initializer and incrementor.] - console.log(x); + console.log('Hello World'); } // for loops with an initializer, termination condition, and incrementor using '++' should remain untouched -for(let x = 1; x < 10; x++) { - console.log(x); +for (let i = 1; i < 10; i++) { + console.log(i); } // for loops with an initializer, termination condition, and incrementor using '+=' should remain untouched -for (let i = 0; i < 10; x+=1) { - console.log(x); +for (let i = 0; i < 10; i+=1) { + console.log(i); } // for loops with an initializer and termination condition should remain untouched