Disallow Duplicate Keys (no-dupe-keys)
Creating objects with duplicate keys in objects can cause unexpected behavior in your application. The no-dupe-keys
rule flags the use of duplicate keys in object literals.
var foo = {
bar: "baz",
bar: "qux"
};
Rule Details
This rule is aimed at preventing possible errors and unexpected behavior that might arise from using duplicate keys in object literals. As such, it warns whenever it finds a duplicate key.
The following patterns are considered warnings:
var foo = {
bar: "baz",
bar: "qux"
};
var foo = {
"bar": "baz",
bar: "qux"
};
var foo = {
0x1: "baz",
1: "qux"
};
The following patterns are considered okay and do not cause warnings:
var foo = {
bar: "baz",
quxx: "qux"
};
Version
This rule was introduced in ESLint 0.0.9.