JS.BASE.NO.DUPE.KEYS

Disallow duplicate keys in object literals

Multiple properties with the same key in object literals can cause unexpected behavior in your application.

Copy
var foo = {
    bar: "baz",
    bar: "qux"
};

Rule Details

This rule disallows duplicate keys in object literals.

Examples of incorrect code for this rule:

Copy
/*eslint no-dupe-keys: "error"*/

var foo = {
    bar: "baz",
    bar: "qux"
};

var foo = {
    "bar": "baz",
    bar: "qux"
};

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

Examples of correct code for this rule:

Copy
/*eslint no-dupe-keys: "error"*/

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

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/