Check for duplicate named exports in exported rest elements/properties (#164)

This commit is contained in:
Kai Cataldo 2016-10-10 10:10:16 -04:00 committed by Henry Zhu
parent 2697bfd820
commit 7dd45f7465
19 changed files with 61 additions and 0 deletions

View File

@ -947,6 +947,8 @@ pp.checkDeclaration = function(node) {
}
} else if (node.type === "ObjectProperty") {
this.checkDeclaration(node.value);
} else if (node.type === "RestElement" || node.type === "RestProperty") {
this.checkDeclaration(node.argument);
} else if (node.type === "Identifier") {
this.checkDuplicateExports(node, node.name);
}

View File

@ -0,0 +1,3 @@
export const foo = 1;
export const [bar, ...foo] = baz;

View File

@ -0,0 +1,3 @@
{
"throws": "`foo` has already been exported. Exported identifiers must be unique. (2:22)"
}

View File

@ -0,0 +1,3 @@
export const [foo, ...bar] = baz;
export const bar = 1;

View File

@ -0,0 +1,3 @@
{
"throws": "`bar` has already been exported. Exported identifiers must be unique. (2:13)"
}

View File

@ -0,0 +1,3 @@
export const foo = 1;
export const [bar, [baz, ...foo]] = qux;

View File

@ -0,0 +1,3 @@
{
"throws": "`foo` has already been exported. Exported identifiers must be unique. (2:28)"
}

View File

@ -0,0 +1,3 @@
export const foo = 1;
export const { bar: [baz, ...foo] } = qux;

View File

@ -0,0 +1,3 @@
{
"throws": "`foo` has already been exported. Exported identifiers must be unique. (2:29)"
}

View File

@ -0,0 +1,2 @@
export const foo = 1;
export const { bar, ...foo } = baz;

View File

@ -0,0 +1,5 @@
{
"sourceType": "module",
"throws": "`foo` has already been exported. Exported identifiers must be unique. (2:23)"
}

View File

@ -0,0 +1,2 @@
export const { foo, ...bar } = baz;
export const bar = 1;

View File

@ -0,0 +1,5 @@
{
"sourceType": "module",
"throws": "`bar` has already been exported. Exported identifiers must be unique. (2:13)"
}

View File

@ -0,0 +1,2 @@
export const foo = 1;
export const { bar: { baz, ...foo } } = qux;

View File

@ -0,0 +1,5 @@
{
"sourceType": "module",
"throws": "`foo` has already been exported. Exported identifiers must be unique. (2:30)"
}

View File

@ -0,0 +1,2 @@
export const foo = 1;
export const [bar, { baz, ...foo }] = qux;

View File

@ -0,0 +1,5 @@
{
"sourceType": "module",
"throws": "`foo` has already been exported. Exported identifiers must be unique. (2:29)"
}

View File

@ -0,0 +1,2 @@
export const foo = 1;
export const [bar, [{ baz, ...foo }]] = qux;

View File

@ -0,0 +1,5 @@
{
"sourceType": "module",
"throws": "`foo` has already been exported. Exported identifiers must be unique. (2:30)"
}