π Disallow useless continue statements.
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
A continue statement at the end of a loop iteration is unnecessary, since the loop advances to the next iteration anyway.
This mirrors the no-useless-return core rule.
Labeled continue statements are ignored, since they may target an outer loop.
// β
for (const item of items) {
process(item);
continue;
}
// β
for (const item of items) {
process(item);
}// β
for (const item of items) {
if (shouldSkip(item)) {
continue;
}
}
// β
for (const item of items) {
if (!shouldSkip(item)) {
// β¦
}
}// β
for (const item of items) {
if (shouldSkip(item)) {
continue;
}
process(item);
}