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).
Flatten module directories unless collocation is earned
Keep related components flat in one folder; only nest a component into its own directory when it has genuinely private companion files.
Bad example
| 1 | components/Ads/ |
| 2 | AdsLayout/ |
| 3 | AdsLayout.tsx |
| 4 | index.ts |
| 5 | Skyscraper/ |
| 6 | Skyscraper.tsx // imports AdLivewrapped |
| 7 | index.ts |
| 8 | AdLivewrapped/ |
| 9 | AdLivewrapped.tsx |
| 10 | index.ts |
Explanation (EN)
Each component gets its own subdirectory and barrel file purely because of import relationships, adding folders and indirection without private companion files to justify them.
Objašnjenje (HR)
Svaka komponenta dobiva vlastiti poddirektorij i barrel datoteku samo zbog odnosa importa, dodajuci mape i indirektnost bez privatnih pratecih datoteka koje bi to opravdale.
Good example
| 1 | components/Ads/ |
| 2 | AdsLayout.tsx |
| 3 | Skyscraper.tsx // imports AdLivewrapped |
| 4 | AdLivewrapped.tsx |
Explanation (EN)
The siblings stay flat and easy to scan. Promote a component into its own directory only when it grows tests, styles, or private subcomponents that belong with it.
Objašnjenje (HR)
Sestrinske komponente ostaju ravne i lako pregledne. Komponentu promakni u vlastiti direktorij tek kad dobije testove, stilove ili privatne podkomponente koje pripadaju uz nju.
Exceptions / Tradeoffs (EN)
Nest a component when it owns private companion files (tests, styles, subcomponents) that should be collocated and not reused elsewhere.
Iznimke / Tradeoffi (HR)
Ugnijezdi komponentu kad posjeduje privatne prateE datoteke (testove, stilove, podkomponente) koje treba drzati uz nju i ne koriste se drugdje.