# Prefer top-level await over top-level promises and async function calls 💼 This rule is enabled in the following [configs](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config): ✅ `recommended`, ☑️ `unopinionated`. 💡 This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). [Top-level await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top_level_await) is more readable and can prevent unhandled rejections. ## Examples ```js // ❌ (async () => { try { await run(); } catch (error) { console.error(error); process.exit(1); } })(); // ❌ async function main() { try { await run(); } catch (error) { console.error(error); process.exit(1); } } main(); // ✅ try { await run(); } catch (error) { console.error(error); process.exit(1); } ``` ```js // ❌ run().catch(error => { console.error(error); process.exit(1); }); // ✅ await run(); ```