Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Delete original code after migrating its functionality
When functionality is moved or extracted to a new home, remove the now-unused originals in the same change rather than leaving orphaned dead code.
Bad example
| 1 | // icons.tsx — every icon below has already been moved into sprite.svg, |
| 2 | // but the components were never deleted |
| 3 | export function SearchIcon() { /* moved to #search */ return <svg>…</svg>; } |
| 4 | export function HistoryIcon() { /* moved to #history */ return <svg>…</svg>; } |
| 5 | // nothing imports these anymore |
Explanation (EN)
The icons now live in the sprite, but the old components remain. Readers can't tell which version is authoritative, and the stale copies will drift out of sync and invite accidental reuse.
Objašnjenje (HR)
Ikone sada žive u spriteu, ali stare komponente su ostale. Čitatelji ne mogu razaznati koja je verzija mjerodavna, a zastarjele kopije će se razići i poticati slučajno ponovno korištenje.
Good example
| 1 | // icons.tsx is deleted entirely once everything references the sprite |
| 2 | <svg width="16" height="16"> |
| 3 | <use href={`${sprite}#search`} /> |
| 4 | </svg> |
Explanation (EN)
The migration is finished in one move: the source of truth is the sprite and the obsolete file is gone, so there is exactly one way to render each icon.
Objašnjenje (HR)
Migracija je dovršena u jednom potezu: izvor istine je sprite, a zastarjela datoteka je obrisana, pa postoji točno jedan način za prikaz svake ikone.
Notes (EN)
If you must keep the old code temporarily (e.g. a phased rollout), make that explicit with a deprecation comment and a tracked follow-up, not silent leftovers.
Bilješke (HR)
Ako stari kod moraš privremeno zadržati (npr. postupno uvođenje), učini to eksplicitnim uz komentar o zastarjelosti i praćeni zadatak, a ne tihim ostacima.