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).
backend ruleP2universalStack: typescript
readabilitystructurecohesion
Keep logic related to one value together in a single block
Group all the code that derives from a particular value (e.g. all selectedEvent handling) in one place rather than scattering it through the function, and order dependent computations correctly.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | let selectedEvent = ...; |
| 2 | // 30 lines of unrelated code |
| 3 | if (selectedEvent) { /* derive pickedDay */ } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const selectedEvent = ...; |
| 2 | if (selectedEvent) { |
| 3 | const startTime = new Date(selectedEvent.startTime); |
| 4 | pickedDay = ...; |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)