no-dupe-keys
NOTE: this rule is part of the
recommended
rule set.Enable full set in
deno.json
:{ "lint": { "rules": { "tags": ["recommended"] } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include
or exclude
array in deno.json
:{ "lint": { "rules": { "include": ["no-dupe-keys"], "exclude": ["no-dupe-keys"] } } }
Disallows duplicate keys in object literals.
Setting the same key multiple times in an object literal will override other assignments to that key and can cause unexpected behaviour.
Invalid:
const foo = {
bar: "baz",
bar: "qux",
};
const foo = {
"bar": "baz",
bar: "qux",
};
const foo = {
0x1: "baz",
1: "qux",
};
Valid:
const foo = {
bar: "baz",
quxx: "qux",
};