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
readabilitylodashclarity
Prefer explicit, self-documenting code over a clever one-liner
Choose a clear, obvious implementation over a terse helper (e.g. lodash xor) when the helper's behaviour is not self-evident at the call site.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codejavascript
| 1 | const isChanged = () => !isEmpty(xor(currentIds, originalIds)); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | const isChanged = () => { |
| 2 | if (currentIds.length !== originalIds.length) return true; |
| 3 | const originalSet = new Set(originalIds); |
| 4 | return currentIds.some((id) => !originalSet.has(id)); |
| 5 | }; |
Explanation (EN)
Objašnjenje (HR)