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).
Don't comment on code that isn't there anymore
A comment explaining a former, now-deleted approach burdens every future reader; git history already preserves that context.
Bad example
| 1 | // This used to fetch the user's settings via getLegacySettings() before we |
| 2 | // switched to the new SettingsService in ticket ABC-123. Keeping this note |
| 3 | // in case we need to revert. |
| 4 | export function getSettings(userId: string) { |
| 5 | return settingsService.fetch(userId); |
| 6 | } |
Explanation (EN)
The comment documents an approach that no longer exists in the code. It burdens every future reader with irrelevant history that git log/blame already preserves, and can mislead readers into thinking the old approach is still relevant.
Objašnjenje (HR)
Komentar opisuje pristup koji vise ne postoji u kodu. Opterecuje svakog buduceg citatelja nebitnom povijescu koju git log/blame vec cuva, i moze zavesti citatelja da misli kako je stari pristup i dalje relevantan.
Good example
| 1 | export function getSettings(userId: string) { |
| 2 | return settingsService.fetch(userId); |
| 3 | } |
Explanation (EN)
The comment is removed entirely. Anyone curious about the previous implementation can find it in version control; the code only documents what it currently does.
Objašnjenje (HR)
Komentar je potpuno uklonjen. Tko god je znatizeljan glede prijasnje implementacije moze je pronaci u verzijskoj kontroli; kod opisuje samo ono sto trenutno radi.
Notes (EN)
This applies to comments about a removed approach, not to comments that explain a non-obvious 'why' behind the current code.
Bilješke (HR)
Ovo vrijedi za komentare o uklonjenom pristupu, ne za komentare koji objasnjavaju ne-ocit 'zasto' iza trenutnog koda.