Skip to content

Commit 798eed7

Browse files
authored
Merge pull request #1232 from ljqx/import-named-assignment
[import/named] fix destructuring assignemnt
2 parents db471a8 + 9a13f81 commit 798eed7

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/ExportMap.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,10 @@ export function recursivePatternCapture(pattern, callback) {
512512
recursivePatternCapture(element, callback)
513513
})
514514
break
515+
516+
case 'AssignmentPattern':
517+
callback(pattern.left)
518+
break
515519
}
516520
}
517521

tests/files/named-exports.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export class ExportedClass {
1414
// destructuring exports
1515

1616
export var { destructuredProp } = {}
17+
, { destructingAssign = null } = {}
18+
, { destructingAssign: destructingRenamedAssign = null } = {}
1719
, [ arrayKeyProp ] = []
1820
, [ { deepProp } ] = []
1921
, { arr: [ ,, deepSparseElement ] } = {}

tests/src/core/getExports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ describe('ExportMap', function () {
273273
context('#size', function () {
274274

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

278278
it('includes exported namespace size', () => expect(ExportMap.get('./export-all', fakeContext))
279279
.to.have.property('size', 1))

tests/src/rules/named.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ ruleTester.run('named', rule, {
2222
test({code: 'import bar, { foo } from "./bar.js"'}),
2323
test({code: 'import {a, b, d} from "./named-exports"'}),
2424
test({code: 'import {ExportedClass} from "./named-exports"'}),
25+
test({code: 'import { destructingAssign } from "./named-exports"'}),
26+
test({code: 'import { destructingRenamedAssign } from "./named-exports"'}),
2527
test({code: 'import { ActionTypes } from "./qc"'}),
2628
test({code: 'import {a, b, c, d} from "./re-export"'}),
2729

0 commit comments

Comments
 (0)