require-await
没有await
表达式的异步函数可能是重构的无意的结果。
规则细节
此规则警告不具有await
表达式的异步函数。
此规则的错误代码示例:
/*eslint require-await: "error"*/
async function foo() {
doSomething();
}
bar(async () => {
doSomething();
});
此规则的正确代码示例:
/*eslint require-await: "error"*/
async function foo() {
await doSomething();
}
bar(async () => {
await doSomething();
});
function foo() {
doSomething();
}
bar(() => {
doSomething();
});
// Allow empty functions.
async function noop() {}
何时不使用它
如果您不想通知没有await
表达式的异步函数,那么禁用此规则是安全的。
相关规则
- require-yieldVersion 此规则在 ESLint 3.11.0.Resources 中引入
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com