Rules Hub
Code Ruleset
← 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 ruleP2stack specificStack: Tailwind
tailwindclsxreadability
Merge paired conditional classes into a single expression
Combine two clsx branches that key off the same condition into one branch with both classes.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | product === 'kapital' ? 'bg-gray-900/50' : 'bg-blue-500', |
| 2 | product === 'kapital' ? 'hover:bg-gray-900/60' : 'hover:bg-blue-400' |
Explanation (EN)
Repeating one condition for a single visual variant can obscure the paired state change.
Objašnjenje (HR)
Good example
New codetsx
| 1 | product === 'kapital' ? 'bg-gray-900/50 hover:bg-gray-900/60' : 'bg-blue-500 hover:bg-blue-400' |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Combine adjacent class-list branches when they evaluate the same side-effect-free condition and the class ordering remains equivalent.
Exceptions / Tradeoffs (EN)
Keep distinct conditions or ordering required by a custom class resolver. Do not merge strings across other arguments when their order affects an intentional conflict-resolution utility.