Skip to main content

require-await

Disallow async functions which do not return promises and have no await expression.

💭

This rule requires type information to run.

This rule extends the base eslint/require-await rule. It uses type information to allow promise-returning functions to be marked as async without containing an await expression.

Examples

Examples of correct code for this rule:

async function returnsPromise1() {
return Promise.resolve(1);
}

const returnsPromise2 = () => returnsPromise1();

Options

See eslint/require-await options.

How to Use

.eslintrc.cjs
module.exports = {
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"require-await": "off",
"@typescript-eslint/require-await": "error"
}
};

Try this rule in the playground ↗

When Not To Use It

Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting. See Troubleshooting > Linting with Type Information > Performance if you experience performance degredations after enabling type checked rules.

Resources

Taken with ❤️ from ESLint core.