@babel/traverse
Advanced tools
Comparing version 7.0.0-beta.44 to 7.0.0-beta.45
@@ -215,9 +215,10 @@ "use strict"; | ||
var typeKey = "is" + type; | ||
var fn = t()[typeKey]; | ||
NodePath.prototype[typeKey] = function (opts) { | ||
return t()[typeKey](this.node, opts); | ||
return fn(this.node, opts); | ||
}; | ||
NodePath.prototype["assert" + type] = function (opts) { | ||
if (!this[typeKey](opts)) { | ||
if (!fn(this.node, opts)) { | ||
throw new TypeError("Expected node path of type " + type); | ||
@@ -224,0 +225,0 @@ } |
@@ -24,2 +24,3 @@ "use strict"; | ||
exports.isConstantExpression = isConstantExpression; | ||
exports.isInStrictMode = isInStrictMode; | ||
exports.is = void 0; | ||
@@ -380,2 +381,40 @@ | ||
return false; | ||
} | ||
function isInStrictMode() { | ||
var start = this.isProgram() ? this : this.parentPath; | ||
var strictParent = start.find(function (path) { | ||
if (path.isProgram({ | ||
sourceType: "module" | ||
})) return true; | ||
if (path.isClass()) return true; | ||
if (!path.isProgram() && !path.isFunction()) return false; | ||
if (path.isArrowFunctionExpression() && !path.get("body").isBlockStatement()) { | ||
return false; | ||
} | ||
var node = path.node; | ||
if (path.isFunction()) node = node.body; | ||
for (var _iterator3 = node.directives, _isArray3 = Array.isArray(_iterator3), _i4 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { | ||
var _ref3; | ||
if (_isArray3) { | ||
if (_i4 >= _iterator3.length) break; | ||
_ref3 = _iterator3[_i4++]; | ||
} else { | ||
_i4 = _iterator3.next(); | ||
if (_i4.done) break; | ||
_ref3 = _i4.value; | ||
} | ||
var directive = _ref3; | ||
if (directive.value.value === "use strict") { | ||
return true; | ||
} | ||
} | ||
}); | ||
return !!strictParent; | ||
} |
@@ -41,6 +41,7 @@ "use strict"; | ||
nodes = this._verifyNodeList(nodes); | ||
var parentPath = this.parentPath; | ||
if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement() || this.parentPath.isExportNamedDeclaration() || this.parentPath.isExportDefaultDeclaration() && this.isDeclaration()) { | ||
return this.parentPath.insertBefore(nodes); | ||
} else if (this.isNodeType("Expression") && this.listKey !== "params" && this.listKey !== "arguments" || this.parentPath.isForStatement() && this.key === "init") { | ||
if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) { | ||
return parentPath.insertBefore(nodes); | ||
} else if (this.isNodeType("Expression") && this.listKey !== "params" && this.listKey !== "arguments" || parentPath.isForStatement() && this.key === "init") { | ||
if (this.node) nodes.push(this.node); | ||
@@ -118,8 +119,18 @@ return this.replaceExpressionWithStatements(nodes); | ||
nodes = this._verifyNodeList(nodes); | ||
var parentPath = this.parentPath; | ||
if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement() || this.parentPath.isExportNamedDeclaration() || this.parentPath.isExportDefaultDeclaration() && this.isDeclaration()) { | ||
return this.parentPath.insertAfter(nodes); | ||
} else if (this.isNodeType("Expression") || this.parentPath.isForStatement() && this.key === "init") { | ||
if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) { | ||
return parentPath.insertAfter(nodes); | ||
} else if (this.isNodeType("Expression") || parentPath.isForStatement() && this.key === "init") { | ||
if (this.node) { | ||
var temp = this.scope.generateDeclaredUidIdentifier(); | ||
var scope = this.scope; | ||
if (parentPath.isMethod({ | ||
computed: true, | ||
key: this.node | ||
})) { | ||
scope = scope.parent; | ||
} | ||
var temp = scope.generateDeclaredUidIdentifier(); | ||
nodes.unshift(t().expressionStatement(t().assignmentExpression("=", t().cloneNode(temp), this.node))); | ||
@@ -126,0 +137,0 @@ nodes.push(t().expressionStatement(t().cloneNode(temp))); |
@@ -106,2 +106,8 @@ "use strict"; | ||
} | ||
} else if (t().isPrivateName(node)) { | ||
gatherNodeParts(node.id, parts); | ||
} else if (t().isThisExpression(node)) { | ||
parts.push("this"); | ||
} else if (t().isSuper(node)) { | ||
parts.push("super"); | ||
} | ||
@@ -629,3 +635,3 @@ } | ||
return true; | ||
} else if (t().isClassProperty(node) || t().isObjectProperty(node)) { | ||
} else if (t().isProperty(node)) { | ||
if (node.computed && !this.isPure(node.key, constantsOnly)) return false; | ||
@@ -632,0 +638,0 @@ return this.isPure(node.value, constantsOnly); |
{ | ||
"name": "@babel/traverse", | ||
"version": "7.0.0-beta.44", | ||
"version": "7.0.0-beta.45", | ||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes", | ||
@@ -11,8 +11,8 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
"dependencies": { | ||
"@babel/code-frame": "7.0.0-beta.44", | ||
"@babel/generator": "7.0.0-beta.44", | ||
"@babel/helper-function-name": "7.0.0-beta.44", | ||
"@babel/helper-split-export-declaration": "7.0.0-beta.44", | ||
"@babel/types": "7.0.0-beta.44", | ||
"babylon": "7.0.0-beta.44", | ||
"@babel/code-frame": "7.0.0-beta.45", | ||
"@babel/generator": "7.0.0-beta.45", | ||
"@babel/helper-function-name": "7.0.0-beta.45", | ||
"@babel/helper-split-export-declaration": "7.0.0-beta.45", | ||
"@babel/types": "7.0.0-beta.45", | ||
"babylon": "7.0.0-beta.45", | ||
"debug": "^3.1.0", | ||
@@ -24,4 +24,4 @@ "globals": "^11.1.0", | ||
"devDependencies": { | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.44" | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.45" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
160973
4632
+ Added@babel/code-frame@7.0.0-beta.45(transitive)
+ Added@babel/generator@7.0.0-beta.45(transitive)
+ Added@babel/helper-function-name@7.0.0-beta.45(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.45(transitive)
+ Added@babel/helper-split-export-declaration@7.0.0-beta.45(transitive)
+ Added@babel/highlight@7.0.0-beta.45(transitive)
+ Added@babel/template@7.0.0-beta.45(transitive)
+ Added@babel/types@7.0.0-beta.45(transitive)
+ Addedbabylon@7.0.0-beta.45(transitive)
- Removed@babel/code-frame@7.0.0-beta.44(transitive)
- Removed@babel/generator@7.0.0-beta.44(transitive)
- Removed@babel/helper-function-name@7.0.0-beta.44(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.44(transitive)
- Removed@babel/helper-split-export-declaration@7.0.0-beta.44(transitive)
- Removed@babel/highlight@7.0.0-beta.44(transitive)
- Removed@babel/template@7.0.0-beta.44(transitive)
- Removed@babel/types@7.0.0-beta.44(transitive)
- Removedbabylon@7.0.0-beta.44(transitive)
Updated@babel/types@7.0.0-beta.45
Updatedbabylon@7.0.0-beta.45