Skip to content

Commit

Permalink
Fix: sort-keys ignores destructuring patterns (fixes #6896) (#6899)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo authored and mysticatea committed Aug 13, 2016
1 parent 3fe3a4f commit b9b3446
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/rules/sort-keys.js
Expand Up @@ -124,6 +124,10 @@ module.exports = {
},

Property(node) {
if (node.parent.type === "ObjectPattern") {
return;
}

const prevName = stack.prevName;
const thisName = getPropertyName(node);

Expand Down
5 changes: 4 additions & 1 deletion tests/lib/rules/sort-keys.js
Expand Up @@ -33,9 +33,12 @@ ruleTester.run("sort-keys", rule, {
// ignore non-simple computed properties.
{code: "var obj = {a:1, b:3, [a + b]: -1, c:2}", options: [], parserOptions: {ecmaVersion: 6}},

// ignore spred properties.
// ignore spread properties.
{code: "var obj = {a:1, ...z, b:1}", options: [], parserOptions: {ecmaVersion: 6, ecmaFeatures: {experimentalObjectRestSpread: true}}},

// ignore destructuring patterns.
{code: "let {a, b} = {}", options: [], parserOptions: {ecmaVersion: 6}},

// nested
{code: "var obj = {a:1, b:{x:1, y:1}, c:1}", options: []},

Expand Down

0 comments on commit b9b3446

Please sign in to comment.