Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Map variants to assets via a data-derived class rather than per-variant branches
Drive category icons from a stable identifier mapping with an explicit fallback; avoid deriving asset classes from localized display names.
Bad example
| 1 | if (category.id === 'MOVIE') return <MovieIcon />; |
| 2 | if (category.id === 'SPORT') return <SportIcon />; |
Explanation (EN)
Repeated conditional branches duplicate the mapping and can omit a new supported category.
Objašnjenje (HR)
Good example
| 1 | const iconClass = iconClasses[category.id] ?? defaultIconClass; |
| 2 | return <span className={iconClass} aria-hidden="true" />; |
Explanation (EN)
This decorative icon uses a stable mapping and fallback; meaningful icon-only content needs its own accessible name.
Objašnjenje (HR)
Notes (EN)
For a category-to-icon mapping, use a stable validated category identifier and a deliberate unknown-category fallback; choose CSS or component assets according to the existing system.
Exceptions / Tradeoffs (EN)
Localized display names can contain spaces or change over time. Missing assets may need a build-time failure rather than silent disappearance, and meaningful icons require an accessible label.