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).
fullstack ruleP2universalStack: javascript
clean-codereadabilityarraysredundancy
Return a transformed value directly instead of holding it in a needless intermediate
When a value is computed only to be returned, return it directly; e.g. don't assign Array.sort()'s in-place result to a new variable just to return it.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejavascript
| 1 | const ratesSorted = rates.sort(cmp); // sort mutates in place |
| 2 | return ratesSorted; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | return rates.sort(cmp); |
Explanation (EN)
Objašnjenje (HR)