mirror of
https://git.proxmox.com/git/pve-eslint
synced 2025-10-13 00:13:04 +00:00

includes a (minimal) working wrapper Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
47 lines
668 B
Markdown
47 lines
668 B
Markdown
# disallow duplicate keys in object literals (no-dupe-keys)
|
|
|
|
Multiple properties with the same key in object literals can cause unexpected behavior in your application.
|
|
|
|
```js
|
|
var foo = {
|
|
bar: "baz",
|
|
bar: "qux"
|
|
};
|
|
```
|
|
|
|
## Rule Details
|
|
|
|
This rule disallows duplicate keys in object literals.
|
|
|
|
Examples of **incorrect** code for this rule:
|
|
|
|
```js
|
|
/*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:
|
|
|
|
```js
|
|
/*eslint no-dupe-keys: "error"*/
|
|
|
|
var foo = {
|
|
bar: "baz",
|
|
quxx: "qux"
|
|
};
|
|
```
|