From 64baa91bd934ffb072dd91e8408c2ce05912a715 Mon Sep 17 00:00:00 2001 From: Zhibin Liu Date: Thu, 15 Nov 2018 19:15:59 +0800 Subject: [PATCH 1/2] [import/named] fix destructuring assignemnt --- src/ExportMap.js | 4 ++++ tests/files/named-exports.js | 2 ++ tests/src/rules/named.js | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/ExportMap.js b/src/ExportMap.js index 66b212a21..563ff9e8c 100644 --- a/src/ExportMap.js +++ b/src/ExportMap.js @@ -512,6 +512,10 @@ export function recursivePatternCapture(pattern, callback) { recursivePatternCapture(element, callback) }) break + + case 'AssignmentPattern': + callback(pattern.left) + break } } diff --git a/tests/files/named-exports.js b/tests/files/named-exports.js index 752092e0a..f2881c10c 100644 --- a/tests/files/named-exports.js +++ b/tests/files/named-exports.js @@ -14,6 +14,8 @@ export class ExportedClass { // destructuring exports export var { destructuredProp } = {} + , { destructingAssign = null } = {} + , { destructingAssign: destructingRenamedAssign = null } = {} , [ arrayKeyProp ] = [] , [ { deepProp } ] = [] , { arr: [ ,, deepSparseElement ] } = {} diff --git a/tests/src/rules/named.js b/tests/src/rules/named.js index cb1a5b843..ed6dc9e04 100644 --- a/tests/src/rules/named.js +++ b/tests/src/rules/named.js @@ -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"'}), From 9a13f811acfc375010c5d45e5655cc1538986904 Mon Sep 17 00:00:00 2001 From: Zhibin Liu Date: Fri, 16 Nov 2018 09:09:45 +0800 Subject: [PATCH 2/2] fix test --- tests/src/core/getExports.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/core/getExports.js b/tests/src/core/getExports.js index 3423fe3e1..3bda3d3db 100644 --- a/tests/src/core/getExports.js +++ b/tests/src/core/getExports.js @@ -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))