unicorn/no-unnecessary-await 正确性
它的作用
禁止对非 Promise 值使用 await。
为什么这不好?
await 操作符应仅用于 Promise 值。
示例
以下是此规则的错误代码示例:
javascript
async function bad() {
await await promise;
}以下是此规则的正确代码示例:
javascript
async function bad() {
await promise;
}如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"unicorn/no-unnecessary-await": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"unicorn/no-unnecessary-await": "error",
},
});bash
oxlint --deny unicorn/no-unnecessary-await版本
此规则添加于 v0.0.12。
