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
typesidsdata-modelingcorrectness
Keep ID-like values as strings unless you do arithmetic on them
IDs that look numeric but are only compared and passed through should stay strings; converting introduces NaN risks and you just convert back later anyway.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | if (category) { |
| 2 | setCurrentCategoryId(Number(category)); // NaN if not numeric, converted back to string for fetch |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (category) { |
| 2 | setCurrentCategoryId(category); // keep as string |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)