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: css
scssdrymixinsmaintainability
Extract repeated SCSS declarations into a parameterized mixin
Replace blocks of the same property set repeated across rules (e.g. flex centering) with a reusable mixin that accepts parameters with sensible defaults.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codescss
| 1 | .a { display: flex; justify-content: center; align-items: center; } |
| 2 | .b { display: flex; justify-content: center; align-items: center; } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codescss
| 1 | @mixin flex($justify: center, $align: center, $direction: row) { |
| 2 | display: flex; |
| 3 | justify-content: $justify; |
| 4 | align-items: $align; |
| 5 | flex-direction: $direction; |
| 6 | } |
| 7 |
|
| 8 | .a { @include flex; } |
| 9 | .b { @include flex($align: flex-start, $direction: column); } |
Explanation (EN)
Objašnjenje (HR)