Tân Nguyễn Tân Nguyễn - 4 months ago 25
Javascript Question

Do we need the rule "checking duplicate keys" in ESLint?

This example is coppied from disallow duplicate keys in object literals (no-dupe-keys):

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

When we call it:


The string
would be thrown. That also means,
foo['bar'] = "baz"
had been overriden, and it couldn't be assigned to. So, you should remove it.

Is it good?

I will take another example:

let element = $('<span/>').text('Hi!');
display: '-webkit-box',
display: '-moz-box'

display: '-webkit-box'
would be overriden and couldn't be assigned, too?

No, it's useful on Chrome,
would be used on FF. So, they are different.

Then, the rule is breaking...

Should it be edited for future?


Yes, we do [need this rule].

Re-assigning a value in an object is at best useless and misleading, at worst it's an outright bug.

Your second example is still a plain old JS object and you're overwriting display.