no-return-await

Disallow return await where the await changes nothing for the caller

deprecatedhas suggestions

An async function already wraps what it returns in a promise, so the caller gets the same result from return load() and from return await load().

Inside a try block the await does matter. Without it, the catch doesn't catch a rejection. The rule doesn't report that case.

--fix-suggestions removes the await.

Examples#

example.js2 problems
async function getUser(id) {
  return await db.find(id);
}

const getItems = async () => await db.all();
example.jsNo problems
async function getUser(id) {
  return db.find(id);
}

async function getUserOrNull(id) {
  try {
    return await db.find(id);
  } catch {
    return null;
  }
}

async function getName(id) {
  const user = await db.find(id);
  return user.name;
}

When not to use it#

With return await, the function is still running when the promise rejects, so it shows up in the error's stack trace. If you want that, leave the rule off. ESLint has deprecated this rule.