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
dryfunctionsreadabilityclean-code
Parameterize direction/variant instead of writing near-duplicate functions
Pass a direction or sign as an argument to one function rather than maintaining separate slideLeft/slideRight functions.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | slideLeft() { this.index--; } |
| 2 | slideRight() { this.index++; } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | slide(direction: number) { this.index += direction; } |
| 2 | // usage: onClick={() => this.slide(-1)} |
Explanation (EN)
Objašnjenje (HR)