Rule: no-async-without-await

Functions marked async must contain an await or return statement.

Rationale

Marking a function as async without using await or returning a value inside it can lead to an unintended promise return and a larger transpiled output. Often the function can be synchronous and the async keyword is there by mistake. Return statements are allowed as sometimes it is desirable to wrap the returned value in a Promise.

Config

Not configurable.

Config examples
"no-async-without-await": true
Schema
null

Code examples:

Do not use the async keyword if it is not needed
"rules": { "no-async-without-await": true }
Passes
async function f() {
    await fetch();
}

const f = async () => {
    await fetch();
};

const f = async () => {
    return 'value';
};
Fails
async function f() {
    fetch();
}

async function f() {
    async function g() {
        await h();
    }
}