Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Do not add a class selector alongside a unique id selector
Remove an unnecessary class qualifier on the same unique-ID target only when it is not a state or specificity constraint.
Bad example
| 1 | const header = document.querySelector('#header.siteHeader'); |
Explanation (EN)
A class qualifier adds no identity information when the known element is always meant to match.
Objašnjenje (HR)
Good example
| 1 | const header = document.querySelector('#header'); |
Explanation (EN)
The selector still targets the same element; no descendant query is removed.
Objašnjenje (HR)
Notes (EN)
For a selector containing both a unique ID and a class on the same element, remove the class only if it is not a state condition or specificity requirement.
Exceptions / Tradeoffs (EN)
A descendant query selects a different element and cannot be replaced with its ancestor ID. Even an ID/class compound can intentionally require the class to be present.