eslint-plugin-await-in-async

0.1.3 • Public • Published

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;

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-plugin-await-in-async

Weekly Downloads

8

Version

0.1.3

License

MIT

Unpacked Size

13.1 kB

Total Files

20

Last publish

Collaborators

  • gzzhanghao