Skip to content

Commit

Permalink
Docs: Add duplicate keys limitation to accessor-pairs (#12124)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic authored and kaicataldo committed Aug 19, 2019
1 parent 320b7bd commit 6886148
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/rules/accessor-pairs.md
Expand Up @@ -164,6 +164,28 @@ var o = {
};
```

Also, this rule does not disallow duplicate keys in object literals, and in certain cases with duplicate keys
might not report a missing pair for a getter/setter, like in the following example:

```js
/*eslint accessor-pairs: "error"*/

// no warnings
var o = {
get a() {
return this.val;
},
a: 1,
set a(value) {
this.val = value;
}
};
```

The code above creates an object with just a setter for the property `"a"`.

See [no-dupe-keys](no-dupe-keys.md) if you also want to disallow duplicate keys in object literals.

## When Not To Use It

You can turn this rule off if you are not concerned with the simultaneous presence of setters and getters on objects.
Expand Down

0 comments on commit 6886148

Please sign in to comment.