eslint-plugin-await-in-async
This rule disallows using await expression outside async functions. See microsoft/TypeScript#38847.
Usage
npm i -D eslint-plugin-await-in-async
module.exports = {
extends: [
'plugin:await-in-async/base'
]
}
Rule Details
Examples of incorrect code for this rule:
await foo;
function foo() {
await bar;
}
async function foo() {
const bar = () => {
await baz;
}
}
Examples of correct code for this rule:
async function foo() {
await bar;
}
function foo() {
const bar = async () => {
await baz;
}
}
Options
This rule has an object option for exceptions:
topLevelAwait: 'allow'
allows top-level await
topLevelAwait
Examples of additional correct code for this rule with the { "topLevelAwait": "allow" }
option:
await foo;