Skip to content

Commit 055742c

Browse files
mysticateailyavolodin
authored andcommitted
Fix: no-dupe-keys type errors (fixes #6886) (#6889)
1 parent e456fd3 commit 055742c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/rules/no-dupe-keys.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ module.exports = {
107107
Property(node) {
108108
const name = astUtils.getStaticPropertyName(node);
109109

110+
// Skip destructuring.
111+
if (node.parent.type !== "ObjectExpression") {
112+
return;
113+
}
114+
110115
// Skip if the name is not static.
111116
if (!name) {
112117
return;

tests/lib/rules/no-dupe-keys.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ruleTester.run("no-dupe-keys", rule, {
2727
{ code: "var x = { a: b, ...c }", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }},
2828
{ code: "var x = { get a() {}, set a (value) {} };", parserOptions: { ecmaVersion: 6 }},
2929
{ code: "var x = { a: 1, b: { a: 2 } };", parserOptions: { ecmaVersion: 6 }},
30+
{ code: "var {a, a} = obj", parserOptions: { ecmaVersion: 6 }},
3031
],
3132
invalid: [
3233
{ code: "var x = { a: b, ['a']: b };", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Duplicate key 'a'.", type: "ObjectExpression"}] },

0 commit comments

Comments
 (0)