Skip to content

Avoid-Infinite-Loops

Sourcery rule id: avoid-infinite-loops

Description

Avoid loops with missing or constant end conditions.

Match

for (;;) {console.log("forever")}

Explanation

Loops with a constant condition, or no terminator, can be useful in certain contexts, but it's easy to forget to break out of them. This rule highlights loops which may never end.