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 ruleP2universalStack: javascript
asyncpromisesreadability
Prefer async/await over manual Promise construction
Use async/await for asynchronous flow instead of hand-written `new Promise`/`.then` chains where await reads more clearly.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejavascript
| 1 | function load() { |
| 2 | return new Promise((resolve) => { |
| 3 | fetchData().then((d) => resolve(transform(d))); |
| 4 | }); |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | async function load() { |
| 2 | const d = await fetchData(); |
| 3 | return transform(d); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)