@babel/traverse 8.0.0-alpha.7 → 8.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +30 -6
- package/lib/index.js.map +1 -1
- package/package.json +11 -11
package/lib/index.js
CHANGED
@@ -63,7 +63,7 @@ const {
|
|
63
63
|
isImportSpecifier,
|
64
64
|
isJSXIdentifier,
|
65
65
|
isJSXMemberExpression,
|
66
|
-
isMemberExpression,
|
66
|
+
isMemberExpression: isMemberExpression$1,
|
67
67
|
isRestElement: nodeIsRestElement,
|
68
68
|
isReferenced: nodeIsReferenced,
|
69
69
|
isScope: nodeIsScope,
|
@@ -95,7 +95,7 @@ function isReferencedMemberExpression() {
|
|
95
95
|
node,
|
96
96
|
parent
|
97
97
|
} = this;
|
98
|
-
return isMemberExpression(node) && nodeIsReferenced(node, parent);
|
98
|
+
return isMemberExpression$1(node) && nodeIsReferenced(node, parent);
|
99
99
|
}
|
100
100
|
function isBindingIdentifier() {
|
101
101
|
const {
|
@@ -632,6 +632,7 @@ const {
|
|
632
632
|
identifier: identifier$3,
|
633
633
|
isArrayExpression,
|
634
634
|
isBinary,
|
635
|
+
isCallExpression: isCallExpression$1,
|
635
636
|
isClass,
|
636
637
|
isClassBody,
|
637
638
|
isClassDeclaration,
|
@@ -642,6 +643,7 @@ const {
|
|
642
643
|
isIdentifier: isIdentifier$5,
|
643
644
|
isImportDeclaration,
|
644
645
|
isLiteral: isLiteral$1,
|
646
|
+
isMemberExpression,
|
645
647
|
isMethod,
|
646
648
|
isModuleSpecifier,
|
647
649
|
isNullLiteral,
|
@@ -1230,13 +1232,23 @@ class Scope {
|
|
1230
1232
|
return true;
|
1231
1233
|
} else if (isUnaryExpression(node)) {
|
1232
1234
|
return this.isPure(node.argument, constantsOnly);
|
1233
|
-
} else if (isTaggedTemplateExpression(node)) {
|
1234
|
-
return matchesPattern$1(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly);
|
1235
1235
|
} else if (isTemplateLiteral(node)) {
|
1236
1236
|
for (const expression of node.expressions) {
|
1237
1237
|
if (!this.isPure(expression, constantsOnly)) return false;
|
1238
1238
|
}
|
1239
1239
|
return true;
|
1240
|
+
} else if (isTaggedTemplateExpression(node)) {
|
1241
|
+
return matchesPattern$1(node.tag, "String.raw") && !this.hasBinding("String", {
|
1242
|
+
noGlobals: true
|
1243
|
+
}) && this.isPure(node.quasi, constantsOnly);
|
1244
|
+
} else if (isMemberExpression(node)) {
|
1245
|
+
return !node.computed && isIdentifier$5(node.object) && node.object.name === "Symbol" && isIdentifier$5(node.property) && node.property.name !== "for" && !this.hasBinding("Symbol", {
|
1246
|
+
noGlobals: true
|
1247
|
+
});
|
1248
|
+
} else if (isCallExpression$1(node)) {
|
1249
|
+
return matchesPattern$1(node.callee, "Symbol.for") && !this.hasBinding("Symbol", {
|
1250
|
+
noGlobals: true
|
1251
|
+
}) && node.arguments.length === 1 && _t.isStringLiteral(node.arguments[0]);
|
1240
1252
|
} else {
|
1241
1253
|
return isPureish(node);
|
1242
1254
|
}
|
@@ -1328,9 +1340,9 @@ class Scope {
|
|
1328
1340
|
kind = "var",
|
1329
1341
|
id
|
1330
1342
|
} = opts;
|
1331
|
-
if (!init && !unique && (kind === "var" || kind === "let") && path.isFunction() && !path.node.name &&
|
1343
|
+
if (!init && !unique && (kind === "var" || kind === "let") && path.isFunction() && !path.node.name && isCallExpression$1(path.parent, {
|
1332
1344
|
callee: path.node
|
1333
|
-
}) && path.parent.arguments.length <= path.node.params.length &&
|
1345
|
+
}) && path.parent.arguments.length <= path.node.params.length && isIdentifier$5(id)) {
|
1334
1346
|
path.pushContainer("params", id);
|
1335
1347
|
path.scope.registerBinding("param", path.get("params")[path.node.params.length - 1]);
|
1336
1348
|
return;
|
@@ -3510,6 +3522,18 @@ function isConstantExpression() {
|
|
3510
3522
|
} = this.node;
|
3511
3523
|
return operator !== "in" && operator !== "instanceof" && this.get("left").isConstantExpression() && this.get("right").isConstantExpression();
|
3512
3524
|
}
|
3525
|
+
if (this.isMemberExpression()) {
|
3526
|
+
return !this.node.computed && this.get("object").isIdentifier({
|
3527
|
+
name: "Symbol"
|
3528
|
+
}) && !this.scope.hasBinding("Symbol", {
|
3529
|
+
noGlobals: true
|
3530
|
+
});
|
3531
|
+
}
|
3532
|
+
if (this.isCallExpression()) {
|
3533
|
+
return this.node.arguments.length === 1 && this.get("callee").matchesPattern("Symbol.for") && !this.scope.hasBinding("Symbol", {
|
3534
|
+
noGlobals: true
|
3535
|
+
}) && this.get("arguments")[0].isStringLiteral();
|
3536
|
+
}
|
3513
3537
|
return false;
|
3514
3538
|
}
|
3515
3539
|
function isInStrictMode() {
|