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: javascript
analyticsdomstructure
Put analytics category attributes at the right DOM level
A tracking category that applies to a whole section belongs higher up on the section element, not duplicated on each item, so the event hierarchy is correct.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejsx
| 1 | items.map(item => <a data-ga-category='section' href={item.url} />) |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejsx
| 1 | <section data-ga-category='section'>{items.map(item => <a href={item.url} />)}</section> |
Explanation (EN)
Objašnjenje (HR)