Don't do the duplicate check if not an identifier (#140)
This commit is contained in:
parent
101e9e5636
commit
1d04d12794
@ -923,11 +923,13 @@ pp.checkExport = function (node, checkNames, isDefault) {
|
|||||||
this.checkDuplicateExports(node, node.declaration.id.name, isDefault);
|
this.checkDuplicateExports(node, node.declaration.id.name, isDefault);
|
||||||
} else if (node.declaration.type === "VariableDeclaration") {
|
} else if (node.declaration.type === "VariableDeclaration") {
|
||||||
for (let declaration of node.declaration.declarations) {
|
for (let declaration of node.declaration.declarations) {
|
||||||
|
if (declaration.id.name) {
|
||||||
this.checkDuplicateExports(declaration, declaration.id.name, isDefault);
|
this.checkDuplicateExports(declaration, declaration.id.name, isDefault);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.state.decorators.length) {
|
if (this.state.decorators.length) {
|
||||||
let isClass = node.declaration && (node.declaration.type === "ClassDeclaration" || node.declaration.type === "ClassExpression");
|
let isClass = node.declaration && (node.declaration.type === "ClassDeclaration" || node.declaration.type === "ClassExpression");
|
||||||
|
|||||||
2
test/fixtures/es2015/modules/duplicate-named-export-destructuring/actual.js
vendored
Normal file
2
test/fixtures/es2015/modules/duplicate-named-export-destructuring/actual.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export const { rhythm } = typography;
|
||||||
|
export const { TypographyStyle } = typography;
|
||||||
312
test/fixtures/es2015/modules/duplicate-named-export-destructuring/expected.json
vendored
Normal file
312
test/fixtures/es2015/modules/duplicate-named-export-destructuring/expected.json
vendored
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 84,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 84,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 37,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 37
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [],
|
||||||
|
"source": null,
|
||||||
|
"declaration": {
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start": 7,
|
||||||
|
"end": 37,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 37
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start": 13,
|
||||||
|
"end": 36,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 36
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "ObjectPattern",
|
||||||
|
"start": 13,
|
||||||
|
"end": 23,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"type": "ObjectProperty",
|
||||||
|
"start": 15,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"method": false,
|
||||||
|
"shorthand": true,
|
||||||
|
"computed": false,
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 15,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"identifierName": "rhythm"
|
||||||
|
},
|
||||||
|
"name": "rhythm"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 15,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"identifierName": "rhythm"
|
||||||
|
},
|
||||||
|
"name": "rhythm"
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"shorthand": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 26,
|
||||||
|
"end": 36,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 36
|
||||||
|
},
|
||||||
|
"identifierName": "typography"
|
||||||
|
},
|
||||||
|
"name": "typography"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "const"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 38,
|
||||||
|
"end": 84,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [],
|
||||||
|
"source": null,
|
||||||
|
"declaration": {
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start": 45,
|
||||||
|
"end": 84,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start": 51,
|
||||||
|
"end": 83,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 45
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "ObjectPattern",
|
||||||
|
"start": 51,
|
||||||
|
"end": 70,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 32
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"type": "ObjectProperty",
|
||||||
|
"start": 53,
|
||||||
|
"end": 68,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"method": false,
|
||||||
|
"shorthand": true,
|
||||||
|
"computed": false,
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 53,
|
||||||
|
"end": 68,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 30
|
||||||
|
},
|
||||||
|
"identifierName": "TypographyStyle"
|
||||||
|
},
|
||||||
|
"name": "TypographyStyle"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 53,
|
||||||
|
"end": 68,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 30
|
||||||
|
},
|
||||||
|
"identifierName": "TypographyStyle"
|
||||||
|
},
|
||||||
|
"name": "TypographyStyle"
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"shorthand": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 73,
|
||||||
|
"end": 83,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 35
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 45
|
||||||
|
},
|
||||||
|
"identifierName": "typography"
|
||||||
|
},
|
||||||
|
"name": "typography"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "const"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user