deno.com

no-dupe-keys

注意: 此规则是 recommended 规则集的一部分。
deno.json 中启用完整规则集
{
  "lint": {
    "tags": ["recommended"]
  }
}
使用 Deno CLI 启用完整规则集
deno lint --tags=recommended

禁止对象字面量中出现重复键。

在对象字面量中多次设置相同的键会覆盖对该键的其他赋值,并可能导致意外行为。

无效

const foo = {
  bar: "baz",
  bar: "qux",
};
const foo = {
  "bar": "baz",
  bar: "qux",
};
const foo = {
  0x1: "baz",
  1: "qux",
};

有效

const foo = {
  bar: "baz",
  quxx: "qux",
};

您找到所需的内容了吗?

隐私政策