Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: typescript
function-signaturedefault-paramsreadability
Default an options parameter to an empty object instead of optional chaining everywhere
Give a trailing options bag a default of {} so call sites read options.x rather than peppering options?.x throughout the function.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | const handleCategoryChange = (id?: number, options?: { resetTicker: boolean }) => { |
| 2 | if (options?.resetTicker) { /* ... */ } |
| 3 | tickerId: options?.resetTicker ? null : selectedTicker?.id, |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const handleCategoryChange = (id?: number, options: { resetTicker?: boolean } = {}) => { |
| 2 | if (options.resetTicker) { /* ... */ } |
| 3 | tickerId: options.resetTicker ? null : selectedTicker?.id, |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)