eslint-plugin-await-in-async
v0.1.3
Published
This rule disallows using await expression outside async functions. See [microsoft/TypeScript#38847](https://github.com/microsoft/TypeScript/issues/38847).
Downloads
19
Readme
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:
/* eslint await-in-async/await-in-async: "error" */
await foo;
function foo() {
await bar;
}
async function foo() {
const bar = () => {
await baz;
}
}
Examples of correct code for this rule:
/* eslint await-in-async/await-in-async: "error" */
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:
/* eslint await-in-async/await-in-async: ["error", { "topLevelAwait": "allow" }] */
await foo;