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: javascript
clean-codecoercionstringsreadability
Coerce a value to string with a template literal instead of an extra cast
Prefer a concise template-literal coercion over declaring an intermediate arrow/cast when you just need a string.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | const newType = () => event.target.value as string; |
| 2 | setSelectedType(newType); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | setSelectedType(`${event.target.value}`); |
Explanation (EN)
Objašnjenje (HR)