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 ruleP1stack specificStack: CSS Modules
css-modulesscopingbug
Scope CSS-module selectors under a class
In a CSS/SCSS module, start every rule with a locally-scoped class. Bare tag selectors and `*` are not localized by the module and leak globally to the whole document. Nest global-ish resets under the component's root class.
PR: profico-org-corpus batch2 (all stacks/products)Created: Jul 26, 2026
Bad example
Old codescss
| 1 | /* Component.module.scss */ |
| 2 | * { box-sizing: border-box; } |
| 3 | a { color: red; } |
Explanation (EN)
These aren't class-scoped, so the module applies them to every element and anchor on the page.
Objašnjenje (HR)
Good example
New codescss
| 1 | /* Component.module.scss */ |
| 2 | .container * { box-sizing: border-box; } |
| 3 | .container a { color: red; } |
Explanation (EN)
Nesting under the root class keeps the styles inside the component.
Objašnjenje (HR)