Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

[docs] Fix prefer-while docs #3888

Merged
merged 1 commit into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/rules/code-examples/preferWhile.examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;) {
Expand All @@ -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');
}
`,
},
Expand Down
12 changes: 6 additions & 6 deletions test/rules/prefer-while/test.ts.fix
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 6 additions & 6 deletions test/rules/prefer-while/test.ts.lint
Original file line number Diff line number Diff line change
@@ -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
Expand Down