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
namingreadabilitybooleanstypes
Name variables by their meaning and reflect their type in hasX booleans
A hasX name implies a boolean; do not assign it a string, and avoid names that suggest the wrong domain concept.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | const hasCategoryLabel = categoryNames?.[0]; // actually a string |
| 2 | const tickerCategory = current || (hasCategoryLabel && { label: hasCategoryLabel }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const categoryLabel = categoryNames?.[0]; // string | undefined |
| 2 | const hasCategoryLabel = Boolean(categoryLabel); |
| 3 | const articleCategory = current || (categoryLabel ? { label: categoryLabel } : undefined); |
Explanation (EN)
Objašnjenje (HR)