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: JavaScript
immutabilitymaparraysfunctional
Transform data with map and spread, not by cloning and mutating
Avoid deep-cloning (e.g. JSON.parse(JSON.stringify(arr))) just to mutate; use .map() returning new objects with spread to derive changed copies without touching the original.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codets
| 1 | const copy = JSON.parse(JSON.stringify(items)); |
| 2 | copy.forEach(i => { i.href = base + i.href; }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | const updated = items.map(i => ({ ...i, href: base + i.href })); |
Explanation (EN)
Objašnjenje (HR)