zertosh / eslint-plugin-no-async-without-await

Enforce that async functions use await

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🚨 DEPRECATED 🚨

This project is deprecated. ESLint introduced a comparable rule to this one in ESLint 3.11.0: https://eslint.org/docs/rules/require-await

eslint-plugin-no-async-without-await

Build Status

Usage

npm install eslint-plugin-no-async-without-await

In your .eslintrc:

{
  "plugins": [
    "no-async-without-await"
  ],
  "rules": {
    "no-async-without-await/no-async-without-await": 1
  }
}

Rule Details

Examples of incorrect code for this rule:

async function f() {
  return true;
}

class C {
  async m() {
    return 2 + 2;
  }
}

Examples of correct code for this rule:

async function f() {
  await ;
  return true;
}

class C {
  async m() {
    await someAsyncProcess();
    return 2 + 2;
  }
}

function f() {
  return someAsyncProcess();
}

Options

  • allowThrow: Allows throw to substitute for await. It's often convenient for an async function simply throw to return a rejected promise.

About

Enforce that async functions use await


Languages

Language:JavaScript 100.0%