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/TypeScript
readabilitysimplificationfunctions
Use a plain variable instead of a function that takes no input
If a helper takes no arguments and just computes a value, declare it as a variable rather than wrapping it in a function.
PR: vinify-frontend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | const getLocationImage = (): string => { |
| 2 | if (type === 'STORE' || !imageUrl) return '/images/store.svg'; |
| 3 | return imageUrl; |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const locationImage = type === 'STORE' || !imageUrl ? '/images/store.svg' : imageUrl; |
Explanation (EN)
Objašnjenje (HR)