require-await
eslint
Suggestion
eslint.config.js
export default [
{
rules: {
"require-await": "error",
},
},
];async function foo() {
doSomething();
}
bar(async () => {
doSomething();
});async function foo() {
await doSomething();
}
bar(async () => {
await doSomething();
});
function baz() {
doSomething();
}
bar(() => {
doSomething();
});
async function resourceManagement() {
await using resource = getAsyncResource();
resource.use();
}
// Allow empty functions.
async function noop() {}Examples from the ESLint documentation.
require-await
eslint
export default [
{
rules: {
"require-await": "error",
},
},
];require-await
eslint plugin · pedantic
{
"rules": {
"require-await": "error"
}
}suspicious/useAwait
suspicious · since 1.4.0
{
"linter": {
"rules": {
"suspicious": {
"useAwait": "error"
}
}
}
}Disallow async functions which do not return promises and have no await expression
Enforce the consistent use of either function declarations or expressions assigned to variables
Require or disallow logical assignment operator shorthand
Require identifiers to match a specified regular expression