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
asyncreadabilitypromises
Make the whole handler async rather than wrapping its body in an async IIFE
If a handler needs await, declare the handler async instead of wrapping the body in a void async IIFE.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codejavascript
| 1 | const handle = (event) => { |
| 2 | void (async () => { |
| 3 | await save(); |
| 4 | })(); |
| 5 | }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | const handle = async (event) => { |
| 2 | await save(); |
| 3 | }; |
Explanation (EN)
Objašnjenje (HR)