Using 'await' outside 'async' functions
m-murasovs opened this issue · comments
Misha commented
I have solitary code examples such as const foo = await bar()
, which cause the Parsing error: Can not use keyword 'await' outside an async function
I cannot find a rule to disable this.
Any tips?
Thanks!
Brandon Mills commented
Top-level await
is still a stage 3 experimental syntax proposal. ESLint will support it natively when it reaches stage 4 and becomes part of the language standard. Until then, we recommend using an external parser that supports this syntax, like @babel/eslint-parser
. (You may also need @babel/plugin-syntax-top-level-await
.)