Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/traverse

Package Overview
Dependencies
Maintainers
6
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/traverse - npm Package Compare versions

Comparing version 7.12.17 to 7.13.0

1

lib/path/context.js

@@ -124,2 +124,3 @@ "use strict";

let path = this.parentPath;
if (this.key === "key" && path.isMethod()) path = path.parentPath;
let target;

@@ -126,0 +127,0 @@

15

lib/path/conversion.js

@@ -98,3 +98,4 @@ "use strict";

allowInsertArrow = true,
specCompliant = false
specCompliant = false,
noNewArrows = !specCompliant
} = {}) {

@@ -105,7 +106,7 @@ if (!this.isArrowFunctionExpression()) {

const thisBinding = hoistFunctionEnvironment(this, specCompliant, allowInsertArrow);
const thisBinding = hoistFunctionEnvironment(this, noNewArrows, allowInsertArrow);
this.ensureBlock();
this.node.type = "FunctionExpression";
if (specCompliant) {
if (!noNewArrows) {
const checkBinding = thisBinding ? null : this.parentPath.scope.generateUidIdentifier("arrowCheckId");

@@ -125,3 +126,3 @@

function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArrow = true) {
function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow = true) {
const thisEnvFn = fnPath.findParent(p => {

@@ -236,6 +237,6 @@ return p.isFunction() && !p.isArrowFunctionExpression() || p.isProgram() || p.isClassProperty({

if (thisPaths.length > 0 || specCompliant) {
if (thisPaths.length > 0 || !noNewArrows) {
thisBinding = getThisBinding(thisEnvFn, inConstructor);
if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) {
if (noNewArrows || inConstructor && hasSuperClass(thisEnvFn)) {
thisPaths.forEach(thisChild => {

@@ -246,3 +247,3 @@ const thisRef = thisChild.isJSX() ? t.jsxIdentifier(thisBinding) : t.identifier(thisBinding);

});
if (specCompliant) thisBinding = null;
if (!noNewArrows) thisBinding = null;
}

@@ -249,0 +250,0 @@ }

@@ -114,3 +114,13 @@ "use strict";

function referencesImport(moduleSource, importName) {
if (!this.isReferencedIdentifier()) return false;
if (!this.isReferencedIdentifier()) {
if ((this.isMemberExpression() || this.isOptionalMemberExpression()) && (this.node.computed ? t.isStringLiteral(this.node.property, {
value: importName
}) : this.node.property.name === importName)) {
const object = this.get("object");
return object.isReferencedIdentifier() && object.referencesImport(moduleSource, "*");
}
return false;
}
const binding = this.scope.getBinding(this.node.name);

@@ -117,0 +127,0 @@ if (!binding || binding.kind !== "module") return false;

@@ -313,4 +313,15 @@ "use strict";

get parent() {
const parent = this.path.findParent(p => p.isScope());
return parent == null ? void 0 : parent.scope;
var _parent;
let parent,
path = this.path;
do {
const isKey = path.key === "key";
path = path.parentPath;
if (isKey && path.isMethod()) path = path.parentPath;
if (path && path.isScope()) parent = path;
} while (path && !parent);
return (_parent = parent) == null ? void 0 : _parent.scope;
}

@@ -459,3 +470,3 @@

toArray(node, i, allowArrayLike) {
toArray(node, i, arrayLikeIsIterable) {
if (t.isIdentifier(node)) {

@@ -491,3 +502,3 @@ const binding = this.getBinding(node.name);

if (allowArrayLike) {
if (arrayLikeIsIterable) {
args.unshift(this.hub.addHelper(helperName));

@@ -494,0 +505,0 @@ helperName = "maybeArrayLike";

@@ -31,3 +31,3 @@ "use strict";

if (!path.scope.bindingIdentifierEquals(state.oldName, state.binding.identifier)) {
path.skip();
skipAllButComputedMethodKey(path);
}

@@ -132,2 +132,15 @@ },

exports.default = Renamer;
exports.default = Renamer;
function skipAllButComputedMethodKey(path) {
if (!path.isMethod() || !path.node.computed) {
path.skip();
return;
}
const keys = t.VISITOR_KEYS[path.type];
for (const key of keys) {
if (key !== "key") path.skipKey(key);
}
}

@@ -68,7 +68,7 @@ "use strict";

let aliases = t.FLIPPED_ALIAS_KEYS[nodeType];
const deprecratedKey = t.DEPRECATED_KEYS[nodeType];
const deprecatedKey = t.DEPRECATED_KEYS[nodeType];
if (deprecratedKey) {
console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecratedKey}`);
aliases = [deprecratedKey];
if (deprecatedKey) {
console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecatedKey}`);
aliases = [deprecatedKey];
}

@@ -75,0 +75,0 @@

{
"name": "@babel/traverse",
"version": "7.12.17",
"version": "7.13.0",
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",

@@ -20,7 +20,7 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>",

"@babel/code-frame": "^7.12.13",
"@babel/generator": "^7.12.17",
"@babel/generator": "^7.13.0",
"@babel/helper-function-name": "^7.12.13",
"@babel/helper-split-export-declaration": "^7.12.13",
"@babel/parser": "^7.12.17",
"@babel/types": "^7.12.17",
"@babel/parser": "^7.13.0",
"@babel/types": "^7.13.0",
"debug": "^4.1.0",

@@ -27,0 +27,0 @@ "globals": "^11.1.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc