promise/valid-params Correctness
它的作用
强制向 Promise 函数传递正确数量的参数。
如果使用 TypeScript,这条规则通常是不必要的。
为什么这不好?
用错误数量的参数调用 Promise 函数可能会导致意外的行为或难以发现的 bug。
示例
以下是此规则的错误代码示例:
javascript
Promise.resolve(1, 2);以下是此规则的正确代码示例:
javascript
Promise.resolve(1);如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["promise"],
"rules": {
"promise/valid-params": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["promise"],
rules: {
"promise/valid-params": "error",
},
});bash
oxlint --deny promise/valid-params --promise-plugin版本
此规则于 v0.7.1 中添加。
