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).
Import shared utilities from their source module
Do not re-export shared helpers through feature-specific constants files unless you are intentionally creating a public module boundary.
Bad example
| 1 | // PortfolioTransactionModal.constants.ts |
| 2 | export { getDefaultDate, getApiTransactionDate } from "utils/static/portfolio/dates"; |
| 3 |
|
| 4 | // useTransactionModalForm.ts |
| 5 | import { getDefaultDate, getApiTransactionDate } from "../PortfolioTransactionModal.constants"; |
Explanation (EN)
The feature constants file becomes an accidental barrel for unrelated shared utilities. That hides the real dependency and makes refactors noisier.
Objašnjenje (HR)
Feature constants file postaje slucajni barrel za nepovezane shared utilse. To skriva stvarnu ovisnost i cini refaktore bucijima.
Good example
| 1 | // useTransactionModalForm.ts |
| 2 | import { getDefaultDate, getApiTransactionDate } from "utils/static/portfolio/dates"; |
| 3 | import { DEFAULT_MODAL_MODE } from "../PortfolioTransactionModal.constants"; |
Explanation (EN)
Shared utilities are imported from the shared module, and feature constants stay feature-specific. The dependency graph remains explicit.
Objašnjenje (HR)
Shared utilsi se importaju iz shared modula, a feature konstante ostaju feature-specific. Graf ovisnosti ostaje eksplicitan.
Exceptions / Tradeoffs (EN)
A dedicated index barrel is fine when the module is intentionally exposing a stable public surface.
Iznimke / Tradeoffi (HR)
Namjenski index barrel je u redu kada modul namjerno izaze stabilnu javnu povrsinu.