pve-eslint/eslint/docs/rules/no-continue.md
Dominik Csapak eb39fafa4f first commit
includes a (minimal) working wrapper

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-06 15:06:03 +02:00

72 lines
1.1 KiB
Markdown

# disallow `continue` statements (no-continue)
The `continue` statement terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration. When used incorrectly it makes code less testable, less readable and less maintainable. Structured control flow statements such as `if` should be used instead.
```js
var sum = 0,
i;
for(i = 0; i < 10; i++) {
if(i >= 5) {
continue;
}
a += i;
}
```
## Rule Details
This rule disallows `continue` statements.
Examples of **incorrect** code for this rule:
```js
/*eslint no-continue: "error"*/
var sum = 0,
i;
for(i = 0; i < 10; i++) {
if(i >= 5) {
continue;
}
a += i;
}
```
```js
/*eslint no-continue: "error"*/
var sum = 0,
i;
labeledLoop: for(i = 0; i < 10; i++) {
if(i >= 5) {
continue labeledLoop;
}
a += i;
}
```
Examples of **correct** code for this rule:
```js
/*eslint no-continue: "error"*/
var sum = 0,
i;
for(i = 0; i < 10; i++) {
if(i < 5) {
a += i;
}
}
```
## Compatibility
* **JSLint**: `continue`