Skip to content

noContinue

¥Summary

¥How to configure

biome.json
{
"linter": {
"rules": {
"nursery": {
"noContinue": "error"
}
}
}
}

¥Description

禁止使用 continue 语句。

¥Disallow continue statements.

continue 语句终止当前循环或带标签循环当前迭代中语句的执行,并继续执行循环的下一次迭代。如果使用不当,会降低代码的可测试性、可读性和可维护性。应该使用结构化的控制流语句,例如 if

¥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.

¥Examples

¥Invalid

let sum = 0,
i;
for(i = 0; i < 10; i++) {
if(i >= 5) {
continue;
}
sum += i;
}
code-block.js:6:9 lint/nursery/noContinue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Unexpected use of continue statement.

4 │ for(i = 0; i < 10; i++) {
5 │ if(i >= 5) {
> 6 │ continue;
^^^^^^^^^
7 │ }
8 │

The continue statement terminates execution of the statements in the current 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.

¥Valid

let sum = 0,
i;
for(i = 0; i < 10; i++) {
if(i < 5) {
sum += i;
}
}

¥Related links