# no-dupe-keys

Disallow duplicate keys in object literals.

Object literals allow keys to be declared multiple times, however this causes unwanted behavior by shadowing the first declaration.

# Invalid Code Examples

let foo = {
    bar: 1,
    baz: 2,
    bar: 3
}
More incorrect examples
let foo = {
    bar,
    baz,
    get bar() {
    }
}
let foo = {
    get bar() {
    },
    set bar(foo)  {
    }
}
More correct examples
let foo = {
    bar: {
        bar: {},
        baz: 5
    },
    baz: {}
}

Source (opens new window)

Last Updated: 11/18/2020, 9:36:33 PM