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).
Pin the current behaviour in a test when you defer a fix out of a no-change PR
When a PR's whole claim is that the output does not move, slipping in a visible fix undercuts that claim even if the fix is right. Defer it, but lock the current behaviour with a named test rather than a comment, so the eventual fix has to be a deliberate edit.
Bad example
| 1 | // TODO: rank 3 should use the bronze placeholder, see ticket |
| 2 | const placeholder = rank < 3 ? rank : "default"; |
Explanation (EN)
A comment does not stop the next refactor from changing the output by accident, and it does not record that the current output was a considered decision.
Objašnjenje (HR)
Komentar ne sprjecava sljedece refaktoriranje da slucajno promijeni izlaz i ne biljezi da je trenutni izlaz bio promisljena odluka.
Good example
| 1 | // Known off-by-one, tracked in TICKET-123. Pinned so the fix has to be deliberate. |
| 2 | it("gives rank 3 a ranked background but the default placeholder", () => { |
| 3 | const url = buildUrl({ avatar: "", rank: 3 }); |
| 4 | expect(url).toContain("background=bronze"); |
| 5 | expect(url).toContain("empty-placeholder-[default]"); |
| 6 | }); |
Explanation (EN)
The odd behaviour is documented as executable fact, and changing it fails a test whose name says exactly what is changing.
Objašnjenje (HR)
Cudno ponasanje dokumentirano je kao izvrsiva cinjenica, a promjena obara test cije ime tocno kaze sto se mijenja.
Notes (EN)
This applies whenever a change is sold as behaviour-preserving: a refactor, a migration, or a performance pass. The pinning test is what makes the claim checkable.
Bilješke (HR)
Vrijedi kad god se promjena predstavlja kao ocuvanje ponasanja: refaktoriranje, migracija ili optimizacija. Test koji fiksira ponasanje cini tvrdnju provjerljivom.