From 6886148d1f528659ec3e125f61ef7a5f4c67556d Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Mon, 19 Aug 2019 21:18:54 +0200 Subject: [PATCH] Docs: Add duplicate keys limitation to accessor-pairs (#12124) --- docs/rules/accessor-pairs.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/rules/accessor-pairs.md b/docs/rules/accessor-pairs.md index 207eedeac21..183bc42b6e6 100644 --- a/docs/rules/accessor-pairs.md +++ b/docs/rules/accessor-pairs.md @@ -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.