promise/no-new-statics Correctness
它的作用
禁止对静态 Promise 方法使用 new 调用。
为什么这不好?
对静态 Promise 方法使用 new 是无效的,并且会在运行时导致 TypeError。
示例
以下是此规则的错误代码示例:
javascript
const x = new Promise.resolve(value);以下是此规则的正确代码示例:
javascript
const x = Promise.resolve(value);如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["promise"],
"rules": {
"promise/no-new-statics": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["promise"],
rules: {
"promise/no-new-statics": "error",
},
});bash
oxlint --deny promise/no-new-statics --promise-plugin版本
此规则在 v0.6.1 中添加。
