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
spreaddryobjectsreadability
Spread an object when copying it with small overrides
When returning a near-identical object with one or two changed fields, spread the source instead of manually re-listing every property.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | return { |
| 2 | credit: prediction.credit, |
| 3 | forecast: forecastNow, |
| 4 | forecastLongTerm: [], |
| 5 | location: prediction.location, |
| 6 | meta: prediction.meta, |
| 7 | sun: prediction.sun, |
| 8 | }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | return { |
| 2 | ...prediction, |
| 3 | forecast: forecastNow, |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)