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).
Use ES modules, not TypeScript namespaces
Organize code with files + imports/exports; avoid namespace Foo { ... }.
Bad example
| 1 | namespace Rocket { |
| 2 | export function launch() { |
| 3 | return 'launched'; |
| 4 | } |
| 5 | } |
| 6 |
|
| 7 | Rocket.launch(); |
Explanation (EN)
Namespaces make dependency boundaries less explicit and don't compose well with modern tooling and bundlers.
Objašnjenje (HR)
Namespace-i sakrivaju granice dependencyja i ne uklapaju se dobro s modernim toolingom i bundlerima.
Good example
| 1 | // rocket.ts |
| 2 | export function launch() { |
| 3 | return 'launched'; |
| 4 | } |
| 5 |
|
| 6 | // app.ts |
| 7 | import {launch} from './rocket'; |
| 8 | launch(); |
Explanation (EN)
Imports/exports make dependencies explicit and work consistently with bundlers, tree-shaking, and code search.
Objašnjenje (HR)
Import/export čini dependencyje eksplicitnima i radi konzistentno s bundlerima, tree-shakingom i pretragom koda.
Exceptions / Tradeoffs (EN)
Only when interfacing with external third-party code that requires namespaces.
Iznimke / Tradeoffi (HR)
Samo kada integriraš vanjski third-party kod koji baš traži namespace.