Skip to content

Latest commit

Β 

History

History
58 lines (44 loc) Β· 1.19 KB

File metadata and controls

58 lines (44 loc) Β· 1.19 KB

no-useless-continue

πŸ“ 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.

Examples

// ❌
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);
}