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).
backend ruleP1universalStack: javascript
asyncpromisescorrectness
Return the promise from callbacks passed to Promise.all
A map callback with a statement body that calls an async function but does not return it yields undefined, so Promise.all does not actually await the work; return the promise.
PR: hegnar-user-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | await Promise.all( |
| 2 | items.map((item) => { |
| 3 | doAsyncWork(item); // not returned -> not awaited |
| 4 | }), |
| 5 | ); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | await Promise.all( |
| 2 | items.map((item) => doAsyncWork(item)), |
| 3 | ); |
Explanation (EN)
Objašnjenje (HR)