eslint/no-proto Restriction
它的作用
禁止使用 __proto__ 属性。
为什么这不好?
__proto__ 属性自 ECMAScript 3.1 起已被弃用, 不应在新代码中使用。请改用 Object.getPrototypeOf 和 Object.setPrototypeOf。
有关更多信息,请参阅 MDN 文档。
示例
以下是此规则的错误代码示例:
javascript
var a = obj.__proto__;
var a = obj["__proto__"];
obj.__proto__ = b;
obj["__proto__"] = b;如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"no-proto": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"no-proto": "error",
},
});bash
oxlint --deny no-proto版本
此规则于 v0.2.14 中添加。
