# no-break-in-nested-loop πŸ“ Disallow `break` and `continue` in nested loops and switches inside loops. πŸ’ΌπŸš« This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). This rule is _disabled_ in the β˜‘οΈ `unopinionated` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). Nested loops can be readable, but `break` and `continue` in nested control flow inside loops are easy to misread because the target is not always obvious. Move the inner loop or switch into a function instead. An unlabeled `continue` inside a `switch` continues the surrounding loop, not the next `case`. Use a labeled `continue` if that is intentional. Labeled `break` and `continue` statements are allowed because their target is explicit. ## Examples ```js // ❌ for (const item of items) { for (const child of item.children) { if (child.done) { break; } } } // βœ… function processChildren(item) { for (const child of item.children) { if (child.done) { break; } } } for (const item of items) { processChildren(item); } ``` ```js // ❌ for (const item of items) { switch (item.type) { case 'hidden': break; case 'visible': continue; } } ``` ```js // βœ… for (const item of items) { for (const child of item.children) { check(child); } } ```