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).
Keep diffs focused — don't reorder imports or lines without reason
Avoid cosmetic reordering (e.g. moving imports) that is unrelated to the change; it inflates the diff and hides the substantive edits from reviewers.
Bad example
| 1 | // the PR only needed to add `sprite`, but every import line moved |
| 2 | -import { Drawer } from './Drawer'; |
| 3 | -import { Search } from './Search'; |
| 4 | -import sprite from '../../sprite.svg'; |
| 5 | +import sprite from '../../sprite.svg'; |
| 6 | +import { Search } from './Search'; |
| 7 | +import { Drawer } from './Drawer'; |
Explanation (EN)
Reordering all the imports turns a one-line addition into a multi-line diff. A reviewer now has to read every moved line to confirm nothing meaningful changed, wasting attention.
Objašnjenje (HR)
Preslagivanje svih importa pretvara dodavanje jedne linije u višelinijski diff. Recenzent sada mora pročitati svaku premještenu liniju da potvrdi kako se ništa bitno nije promijenilo, trošeći pažnju.
Good example
| 1 | // add the new import in place, leave the rest untouched |
| 2 | import { Drawer } from './Drawer'; |
| 3 | import { Search } from './Search'; |
| 4 | +import sprite from '../../sprite.svg'; |
Explanation (EN)
Only the genuinely new line shows up in the diff, so the reviewer immediately sees the actual change and nothing else.
Objašnjenje (HR)
U diffu se pojavljuje samo stvarno nova linija, pa recenzent odmah vidi pravu promjenu i ništa drugo.
Notes (EN)
If an import-sorting tool or linter mandates an order, let it run as its own dedicated commit/PR rather than mixing the churn into feature work.
Bilješke (HR)
Ako alat za sortiranje importa ili linter nameće redoslijed, neka se izvrši u zasebnom commitu/PR-u umjesto da se to miješanje uvuče u rad na funkcionalnosti.