Skip to content

Commit

Permalink
Merge pull request #1232 from ljqx/import-named-assignment
Browse files Browse the repository at this point in the history
[import/named] fix destructuring assignemnt
  • Loading branch information
ljharb authored Nov 16, 2018
2 parents db471a8 + 9a13f81 commit 798eed7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
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: 1 addition & 1 deletion tests/src/core/getExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ describe('ExportMap', function () {
context('#size', function () {

it('counts the names', () => expect(ExportMap.get('./named-exports', fakeContext))
.to.have.property('size', 8))
.to.have.property('size', 10))

it('includes exported namespace size', () => expect(ExportMap.get('./export-all', fakeContext))
.to.have.property('size', 1))
Expand Down
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 798eed7

Please sign in to comment.