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).
fullstack ruleP2universalStack: TypeScript
namingreadabilityjsdocutilities
Give utility functions descriptive names and JSDoc
Name a helper after what it does, not its raw transformation; if the name cannot fully convey intent, add a JSDoc comment explaining its behavior.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | export const asString = (v: string | string[] | undefined): string | undefined => |
| 2 | Array.isArray(v) ? v[0] : v; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | /** Returns the first value of a query param that may arrive as a repeated array. */ |
| 2 | export const firstQueryValue = (v: string | string[] | undefined): string | undefined => |
| 3 | Array.isArray(v) ? v[0] : v; |
Explanation (EN)
Objašnjenje (HR)