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 ruleP1universalStack: Node / Next.js
side-effectsmodulesimportsarchitecture
Modules should only export; never run side-effecting work at import time
Route/module files should declare and export. Side effects (fetches, IO) at the top level run on import, which is unexpected — only scripts invoked directly should execute work.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | async function checkServices() { await fetch('...'); } |
| 2 | checkServices(); // runs on import — surprising side effect |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | export async function checkServices() { await fetch('...'); } |
| 2 | // caller decides when to run it |
Explanation (EN)
Objašnjenje (HR)