Skip to content

prefer-await-in-async-return

Prefer explicit await for proven Promise .then calls; the default scope checks direct async returns.

Why

Promise callback chains mix explicit async control flow with nested callbacks, making sequencing and failure handling harder to read.

Fix

Consider awaiting the Promise and returning the transformed value with ordinary async statements. Preserve catch boundaries, callback behavior, and observable scheduling when rewriting manually.

Examples

Before — flagged Do not directly return a Promise callback chain from async code
src/load.ts
async function load() {
return Promise.resolve(1).then((value) => value + 1);
}
After — preferred Use explicit async control flow
src/load.ts
async function load() {
const value = await Promise.resolve(1);
return value + 1;
}

Options

{
"additionalProperties": false,
"properties": {
"scope": { "enum": ["async-return", "all-promise-calls"], "type": "string" }
},
"type": "object"
}