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: react
reactcss-variablesinline-stylessimplicity
Assign possibly-undefined values directly into inline style objects
Set CSS custom properties to a value that may be undefined; undefined keys are excluded from the style object automatically, so no manual guards are needed.
PR: hegnar-components · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | const style = {}; |
| 2 | if (fixedDesktopHeight) style['--fixed-desktop-height'] = fixedDesktopHeight; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const style = { |
| 2 | '--fixed-desktop-height': fixedDesktopHeight, // undefined just drops out |
| 3 | '--fixed-mobile-height': fixedMobileHeight, |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)