]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/no-dupe-keys.md
bump version to 8.4.0-3
[pve-eslint.git] / eslint / docs / rules / no-dupe-keys.md
1 # disallow duplicate keys in object literals (no-dupe-keys)
2
3 Multiple properties with the same key in object literals can cause unexpected behavior in your application.
4
5 ```js
6 var foo = {
7 bar: "baz",
8 bar: "qux"
9 };
10 ```
11
12 ## Rule Details
13
14 This rule disallows duplicate keys in object literals.
15
16 Examples of **incorrect** code for this rule:
17
18 ```js
19 /*eslint no-dupe-keys: "error"*/
20
21 var foo = {
22 bar: "baz",
23 bar: "qux"
24 };
25
26 var foo = {
27 "bar": "baz",
28 bar: "qux"
29 };
30
31 var foo = {
32 0x1: "baz",
33 1: "qux"
34 };
35 ```
36
37 Examples of **correct** code for this rule:
38
39 ```js
40 /*eslint no-dupe-keys: "error"*/
41
42 var foo = {
43 bar: "baz",
44 quxx: "qux"
45 };
46 ```