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).
Define the minimal request contract before threading props
Before adding hook props, fetch args, or service params, define the actual inputs the flow needs and pass only those through the stack.
Bad example
| 1 | export const useFetchPortfolioTransactions = ({ |
| 2 | authToken, |
| 3 | portfolioId, |
| 4 | instruments, |
| 5 | showSnackbar, |
| 6 | }: UseFetchPortfolioTransactionsProps) => { |
| 7 | return fetchPortfolioTransactions({ authToken, portfolioId }); |
| 8 | }; |
Explanation (EN)
The flow accepts and forwards props before verifying they are truly needed. This creates dead parameters, broader interfaces, and review churn later.
Objašnjenje (HR)
Flow prima i prosljeduje propsove prije nego sto se provjeri jesu li stvarno potrebni. To stvara dead parametre, sire interfaceove i review churn kasnije.
Good example
| 1 | interface UseFetchPortfolioTransactionsProps { |
| 2 | portfolioId: number | null; |
| 3 | instruments: PortfolioInstrument[]; |
| 4 | showSnackbar: (params: ShowSnackbarParams) => void; |
| 5 | } |
| 6 |
|
| 7 | export const useFetchPortfolioTransactions = ({ |
| 8 | portfolioId, |
| 9 | instruments, |
| 10 | showSnackbar, |
| 11 | }: UseFetchPortfolioTransactionsProps) => { |
| 12 | return fetchPortfolioTransactions({ portfolioId }); |
| 13 | }; |
Explanation (EN)
The contract is defined from the actual flow requirements. Only required inputs are threaded through the hook, fetch layer, route, and service.
Objašnjenje (HR)
Contract je definiran iz stvarnih zahtjeva flowa. Samo potrebni inputi prolaze kroz hook, fetch layer, route i service.
Notes (EN)
For new data flows, decide these first: required inputs, auth mechanism, pagination ownership, error handling, and response shape.
Bilješke (HR)
Za nove data flowove prvo odluci ovo: required inpute, auth mehanizam, ownership paginacije, error handling i response shape.
Exceptions / Tradeoffs (EN)
Temporary over-provisioning is acceptable only when a follow-up change in the same PR uses the extra prop and the intent is documented.
Iznimke / Tradeoffi (HR)
Privremeno over-provisioning je prihvatljiv samo kada dodatni prop koristi follow-up promjena u istom PR-u i namjera je dokumentirana.