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).
Do not use default exports
Use named exports to keep imports consistent and avoid ambiguous naming.
Bad example
| 1 | // foo.ts |
| 2 | const foo = 'value'; |
| 3 | export default foo; |
| 4 |
|
| 5 | // bar.ts |
| 6 | import anythingName from './foo'; |
| 7 | console.log(anythingName); |
Explanation (EN)
Default exports have no canonical name, which makes refactors and code search harder and allows confusing import renames.
Objašnjenje (HR)
Default export nema kanonsko ime pa su refaktori i pretraga koda teži, a import se može preimenovati u bilo što i postati zbunjujuće.
Good example
| 1 | // foo.ts |
| 2 | export const foo = 'value'; |
| 3 |
|
| 4 | // bar.ts |
| 5 | import {foo} from './foo'; |
| 6 | console.log(foo); |
Explanation (EN)
Named exports enforce consistent imports and fail fast when you try to import something that doesn't exist.
Objašnjenje (HR)
Named export forsira konzistentne importe i odmah javlja grešku ako pokušaš importati nešto što ne postoji.
Exceptions / Tradeoffs (EN)
Only use default exports if you are forced by an external ecosystem you cannot change (rare).
Iznimke / Tradeoffi (HR)
Default export koristi samo ako te vanjski ekosustav na to prisili i ne možeš to promijeniti (rijetko).