Skip to content

Commit

Permalink
[import/named] fix destructuring assignemnt
Browse files Browse the repository at this point in the history
  • Loading branch information
ljqx committed Nov 15, 2018
1 parent db471a8 commit 64baa91
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ export function recursivePatternCapture(pattern, callback) {
recursivePatternCapture(element, callback)
})
break

case 'AssignmentPattern':
callback(pattern.left)
break
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/files/named-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class ExportedClass {
// destructuring exports

export var { destructuredProp } = {}
, { destructingAssign = null } = {}
, { destructingAssign: destructingRenamedAssign = null } = {}
, [ arrayKeyProp ] = []
, [ { deepProp } ] = []
, { arr: [ ,, deepSparseElement ] } = {}
2 changes: 2 additions & 0 deletions tests/src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ ruleTester.run('named', rule, {
test({code: 'import bar, { foo } from "./bar.js"'}),
test({code: 'import {a, b, d} from "./named-exports"'}),
test({code: 'import {ExportedClass} from "./named-exports"'}),
test({code: 'import { destructingAssign } from "./named-exports"'}),
test({code: 'import { destructingRenamedAssign } from "./named-exports"'}),
test({code: 'import { ActionTypes } from "./qc"'}),
test({code: 'import {a, b, c, d} from "./re-export"'}),

Expand Down

0 comments on commit 64baa91

Please sign in to comment.