Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP2universalStack: any
control-flowreadabilityloopsclean-code
Avoid while(true) loops with internal breaks
Express the loop's exit condition in the while clause rather than relying on a break inside an infinite loop.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | while (true) { |
| 2 | const batch = items.splice(0, 5); |
| 3 | if (batch.length === 0) break; |
| 4 | process(batch); |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | while (items.length > 0) { |
| 2 | process(items.splice(0, 5)); |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)