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 ruleP2stack specificStack: React/SCSS Modules
css-modulesclsxhelpers
Return resolved CSS-module class names from helpers
Have class-name helpers return the actual CSS-module class (via clsx) instead of returning a space-joined string that callers must split.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | const getClass = (change) => change > 0 ? 'changeInShares positive' : 'changeInShares negative'; |
| 2 | <div className={styles[item.class.split(' ')[0]]}> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const getClassName = (change) => clsx(styles.changeInShares, { |
| 2 | [styles.positive]: change > 0, |
| 3 | [styles.negative]: change < 0, |
| 4 | }); |
Explanation (EN)
Objašnjenje (HR)