Skip to content

Commit

Permalink
Fix: no-dupe-keys type errors (fixes #6886) (#6889)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea authored and ilyavolodin committed Aug 12, 2016
1 parent e456fd3 commit 055742c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/rules/no-dupe-keys.js
Expand Up @@ -107,6 +107,11 @@ module.exports = {
Property(node) {
const name = astUtils.getStaticPropertyName(node);

// Skip destructuring.
if (node.parent.type !== "ObjectExpression") {
return;
}

// Skip if the name is not static.
if (!name) {
return;
Expand Down
1 change: 1 addition & 0 deletions tests/lib/rules/no-dupe-keys.js
Expand Up @@ -27,6 +27,7 @@ ruleTester.run("no-dupe-keys", rule, {
{ code: "var x = { a: b, ...c }", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }},
{ code: "var x = { get a() {}, set a (value) {} };", parserOptions: { ecmaVersion: 6 }},
{ code: "var x = { a: 1, b: { a: 2 } };", parserOptions: { ecmaVersion: 6 }},
{ code: "var {a, a} = obj", parserOptions: { ecmaVersion: 6 }},
],
invalid: [
{ code: "var x = { a: b, ['a']: b };", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Duplicate key 'a'.", type: "ObjectExpression"}] },
Expand Down

0 comments on commit 055742c

Please sign in to comment.