no-dupe-keys
Disallow duplicate keys in object literals
✅ Recommended
Using the recommended
config from @eslint/js
in a configuration file enables this rule
Multiple properties with the same key in object literals can cause unexpected behavior in your application.
var foo = {
bar: "baz",
bar: "qux"
};
Rule Details
This rule disallows duplicate keys in object literals.
Examples of incorrect code for this rule:
Open in Playground
/*eslint no-dupe-keys: "error"*/
var foo = {
bar: "baz",
: "qux"
};
var foo = {
"bar": "baz",
: "qux"
};
var foo = {
0x1: "baz",
: "qux"
};
Examples of correct code for this rule:
Open in Playground
/*eslint no-dupe-keys: "error"*/
var foo = {
bar: "baz",
quxx: "qux"
};
Handled by TypeScript
It is safe to disable this rule when using TypeScript because TypeScript's compiler enforces this check.
Version
This rule was introduced in ESLint v0.0.9.