Updating NPM dependencies

This commit is contained in:
Drew Heavner
2020-11-11 13:30:52 +00:00
committed by GitHub
parent 7a6fb66c63
commit bd487ef324
9068 changed files with 1400893 additions and 587661 deletions

View File

@@ -31,7 +31,7 @@ class TraversalContext {
if (opts.enter || opts.exit) return true;
if (opts[node.type]) return true;
const keys = t.VISITOR_KEYS[node.type];
if (!keys || !keys.length) return false;
if (!(keys == null ? void 0 : keys.length)) return false;
for (const key of keys) {
if (node[key]) return true;

View File

@@ -30,8 +30,6 @@ var visitors = _interopRequireWildcard(require("./visitors"));
exports.visitors = visitors;
var _includes = _interopRequireDefault(require("lodash/includes"));
var t = _interopRequireWildcard(require("@babel/types"));
var cache = _interopRequireWildcard(require("./cache"));
@@ -95,15 +93,15 @@ traverse.removeProperties = function (tree, opts) {
return tree;
};
function hasBlacklistedType(path, state) {
function hasDenylistedType(path, state) {
if (path.node.type === state.type) {
state.has = true;
path.stop();
}
}
traverse.hasType = function (tree, type, blacklistTypes) {
if ((0, _includes.default)(blacklistTypes, tree.type)) return false;
traverse.hasType = function (tree, type, denylistTypes) {
if (denylistTypes == null ? void 0 : denylistTypes.includes(tree.type)) return false;
if (tree.type === type) return true;
const state = {
has: false,
@@ -111,8 +109,8 @@ traverse.hasType = function (tree, type, blacklistTypes) {
};
traverse(tree, {
noScope: true,
blacklist: blacklistTypes,
enter: hasBlacklistedType
denylist: denylistTypes,
enter: hasDenylistedType
}, null, state);
return state.has;
};

View File

@@ -25,9 +25,9 @@ function shareCommentsWithSiblings() {
const hasPrev = Boolean(prev.node);
const hasNext = Boolean(next.node);
if (hasPrev && hasNext) {} else if (hasPrev) {
if (hasPrev && !hasNext) {
prev.addComments("trailing", trailing);
} else if (hasNext) {
} else if (hasNext && !hasPrev) {
next.addComments("leading", leading);
}
}

View File

@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
});
exports.call = call;
exports._call = _call;
exports.isBlacklisted = isBlacklisted;
exports.isBlacklisted = exports.isDenylisted = isDenylisted;
exports.visit = visit;
exports.skip = skip;
exports.skipKey = skipKey;
@@ -69,9 +69,11 @@ function _call(fns) {
return false;
}
function isBlacklisted() {
const blacklist = this.opts.blacklist;
return blacklist && blacklist.indexOf(this.node.type) > -1;
function isDenylisted() {
var _this$opts$denylist;
const denylist = (_this$opts$denylist = this.opts.denylist) != null ? _this$opts$denylist : this.opts.blacklist;
return denylist && denylist.indexOf(this.node.type) > -1;
}
function visit() {
@@ -79,7 +81,7 @@ function visit() {
return false;
}
if (this.isBlacklisted()) {
if (this.isDenylisted()) {
return false;
}
@@ -221,9 +223,11 @@ function setup(parentPath, container, listKey, key) {
}
function setKey(key) {
var _this$node;
this.key = key;
this.node = this.container[this.key];
this.type = this.node && this.node.type;
this.type = (_this$node = this.node) == null ? void 0 : _this$node.type;
}
function requeue(pathToQueue = this) {

View File

@@ -127,7 +127,7 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro
static: false
});
});
const inConstructor = thisEnvFn && thisEnvFn.node.kind === "constructor";
const inConstructor = (thisEnvFn == null ? void 0 : thisEnvFn.node.kind) === "constructor";
if (thisEnvFn.isClassProperty()) {
throw fnPath.buildCodeFrameError("Unable to transform arrow inside class property");

View File

@@ -132,7 +132,7 @@ function _evaluate(path, state) {
return deopt(binding.path, state);
}
if (binding && binding.hasValue) {
if (binding == null ? void 0 : binding.hasValue) {
return binding.value;
} else {
if (node.name === "undefined") {
@@ -197,7 +197,7 @@ function _evaluate(path, state) {
if (elemValue.confident) {
arr.push(elemValue.value);
} else {
return deopt(elem, state);
return deopt(elemValue.deopt, state);
}
}
@@ -220,7 +220,7 @@ function _evaluate(path, state) {
key = key.evaluate();
if (!key.confident) {
return deopt(keyPath, state);
return deopt(key.deopt, state);
}
key = key.value;
@@ -234,7 +234,7 @@ function _evaluate(path, state) {
let value = valuePath.evaluate();
if (!value.confident) {
return deopt(valuePath, state);
return deopt(value.deopt, state);
}
value = value.value;

View File

@@ -41,27 +41,43 @@ function addCompletionRecords(path, paths) {
return paths;
}
function findBreak(statements) {
let breakStatement;
if (!Array.isArray(statements)) {
statements = [statements];
}
for (const statement of statements) {
if (statement.isDoExpression() || statement.isProgram() || statement.isBlockStatement() || statement.isCatchClause() || statement.isLabeledStatement()) {
breakStatement = findBreak(statement.get("body"));
} else if (statement.isIfStatement()) {
var _findBreak;
breakStatement = (_findBreak = findBreak(statement.get("consequent"))) != null ? _findBreak : findBreak(statement.get("alternate"));
} else if (statement.isTryStatement()) {
var _findBreak2;
breakStatement = (_findBreak2 = findBreak(statement.get("block"))) != null ? _findBreak2 : findBreak(statement.get("handler"));
} else if (statement.isBreakStatement()) {
breakStatement = statement;
}
if (breakStatement) {
return breakStatement;
}
}
return null;
}
function completionRecordForSwitch(cases, paths) {
let isLastCaseWithConsequent = true;
for (let i = cases.length - 1; i >= 0; i--) {
const switchCase = cases[i];
const consequent = switchCase.get("consequent");
let breakStatement;
findBreak: for (const statement of consequent) {
if (statement.isBlockStatement()) {
for (const statementInBlock of statement.get("body")) {
if (statementInBlock.isBreakStatement()) {
breakStatement = statementInBlock;
break findBreak;
}
}
} else if (statement.isBreakStatement()) {
breakStatement = statement;
break;
}
}
let breakStatement = findBreak(consequent);
if (breakStatement) {
while (breakStatement.key === 0 && breakStatement.parentPath.isBlockStatement()) {

View File

@@ -57,22 +57,22 @@ exports.SHOULD_SKIP = SHOULD_SKIP;
class NodePath {
constructor(hub, parent) {
this.parent = parent;
this.hub = hub;
this.contexts = [];
this.data = null;
this._traverseFlags = 0;
this.state = null;
this.opts = null;
this._traverseFlags = 0;
this.skipKeys = null;
this.parentPath = null;
this.context = null;
this.container = null;
this.listKey = null;
this.key = null;
this.node = null;
this.scope = null;
this.type = null;
this.parent = parent;
this.hub = hub;
this.data = null;
this.context = null;
this.scope = null;
}
static get({

View File

@@ -26,6 +26,8 @@ function getTypeAnnotation() {
}
function _getTypeAnnotation() {
var _inferer;
const node = this.node;
if (!node) {
@@ -59,7 +61,7 @@ function _getTypeAnnotation() {
inferer = inferers[this.parentPath.type];
if (inferer && inferer.validParent) {
if ((_inferer = inferer) == null ? void 0 : _inferer.validParent) {
return this.parentPath.getTypeAnnotation();
}
}

View File

@@ -50,9 +50,19 @@ function getTypeAnnotationBindingConstantViolations(binding, path, name) {
}
}
if (types.length) {
return t.createUnionTypeAnnotation(types);
if (!types.length) {
return;
}
if (t.isTSTypeAnnotation(types[0]) && t.createTSUnionType) {
return t.createTSUnionType(types);
}
if (t.createFlowUnionType) {
return t.createFlowUnionType(types);
}
return t.createUnionTypeAnnotation(types);
}
function getConstantViolationsBefore(binding, path, functions) {
@@ -165,6 +175,20 @@ function getConditionalAnnotation(binding, path, name) {
}
if (types.length) {
if (t.isTSTypeAnnotation(types[0]) && t.createTSUnionType) {
return {
typeAnnotation: t.createTSUnionType(types),
ifStatement
};
}
if (t.createFlowUnionType) {
return {
typeAnnotation: t.createFlowUnionType(types),
ifStatement
};
}
return {
typeAnnotation: t.createUnionTypeAnnotation(types),
ifStatement

View File

@@ -44,12 +44,14 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function VariableDeclarator() {
var _type;
const id = this.get("id");
if (!id.isIdentifier()) return;
const init = this.get("init");
let type = init.getTypeAnnotation();
if (type && type.type === "AnyTypeAnnotation") {
if (((_type = type) == null ? void 0 : _type.type) === "AnyTypeAnnotation") {
if (init.isCallExpression() && init.get("callee").isIdentifier({
name: "Array"
}) && !init.scope.hasBinding("Array", true)) {
@@ -112,11 +114,31 @@ function BinaryExpression(node) {
}
function LogicalExpression() {
return t.createUnionTypeAnnotation([this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()]);
const argumentTypes = [this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()];
if (t.isTSTypeAnnotation(argumentTypes[0]) && t.createTSUnionType) {
return t.createTSUnionType(argumentTypes);
}
if (t.createFlowUnionType) {
return t.createFlowUnionType(argumentTypes);
}
return t.createUnionTypeAnnotation(argumentTypes);
}
function ConditionalExpression() {
return t.createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()]);
const argumentTypes = [this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()];
if (t.isTSTypeAnnotation(argumentTypes[0]) && t.createTSUnionType) {
return t.createTSUnionType(argumentTypes);
}
if (t.createFlowUnionType) {
return t.createFlowUnionType(argumentTypes);
}
return t.createUnionTypeAnnotation(argumentTypes);
}
function SequenceExpression() {

View File

@@ -24,16 +24,12 @@ exports.isConstantExpression = isConstantExpression;
exports.isInStrictMode = isInStrictMode;
exports.is = void 0;
var _includes = _interopRequireDefault(require("lodash/includes"));
var t = _interopRequireWildcard(require("@babel/types"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function matchesPattern(pattern, allowPartial) {
return t.matchesPattern(this.node, pattern, allowPartial);
}
@@ -110,7 +106,7 @@ function isStatementOrBlock() {
if (this.parentPath.isLabeledStatement() || t.isBlockStatement(this.container)) {
return false;
} else {
return (0, _includes.default)(t.STATEMENT_OR_BLOCK_KEYS, this.key);
return t.STATEMENT_OR_BLOCK_KEYS.includes(this.key);
}
}

View File

@@ -15,11 +15,15 @@ var _removalHooks = require("./lib/removal-hooks");
var _index = require("./index");
function remove() {
var _this$opts;
this._assertUnremoved();
this.resync();
this._removeFromScope();
if (!((_this$opts = this.opts) == null ? void 0 : _this$opts.noScope)) {
this._removeFromScope();
}
if (this._callRemovalHooks()) {
this._markRemoved();

View File

@@ -172,7 +172,7 @@ function _replaceWith(node) {
t.validate(this.parent, this.key, node);
}
this.debug(`Replace with ${node && node.type}`);
this.debug(`Replace with ${node == null ? void 0 : node.type}`);
this.node = this.container[this.key] = node;
}
@@ -185,7 +185,7 @@ function replaceExpressionWithStatements(nodes) {
}
const functionParent = this.getFunctionParent();
const isParentAsync = functionParent && functionParent.is("async");
const isParentAsync = functionParent == null ? void 0 : functionParent.is("async");
const container = t.arrowFunctionExpression([], t.blockStatement(nodes));
this.replaceWith(t.callExpression(container, []));
this.traverse(hoistVariablesVisitor);

View File

@@ -12,15 +12,15 @@ class Binding {
path,
kind
}) {
this.identifier = identifier;
this.scope = scope;
this.path = path;
this.kind = kind;
this.constantViolations = [];
this.constant = true;
this.referencePaths = [];
this.referenced = false;
this.references = 0;
this.identifier = identifier;
this.scope = scope;
this.path = path;
this.kind = kind;
this.clearValue();
}

View File

@@ -5,16 +5,10 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = void 0;
var _includes = _interopRequireDefault(require("lodash/includes"));
var _repeat = _interopRequireDefault(require("lodash/repeat"));
var _renamer = _interopRequireDefault(require("./lib/renamer"));
var _index = _interopRequireDefault(require("../index"));
var _defaults = _interopRequireDefault(require("lodash/defaults"));
var _binding = _interopRequireDefault(require("./binding"));
var _globals = _interopRequireDefault(require("globals"));
@@ -30,37 +24,143 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function gatherNodeParts(node, parts) {
if (t.isModuleDeclaration(node)) {
if (node.source) {
gatherNodeParts(node.source, parts);
} else if (node.specifiers && node.specifiers.length) {
for (const specifier of node.specifiers) {
gatherNodeParts(specifier, parts);
switch (node == null ? void 0 : node.type) {
default:
if (t.isModuleDeclaration(node)) {
if (node.source) {
gatherNodeParts(node.source, parts);
} else if (node.specifiers && node.specifiers.length) {
for (const e of node.specifiers) gatherNodeParts(e, parts);
} else if (node.declaration) {
gatherNodeParts(node.declaration, parts);
}
} else if (t.isModuleSpecifier(node)) {
gatherNodeParts(node.local, parts);
} else if (t.isLiteral(node)) {
parts.push(node.value);
}
} else if (node.declaration) {
gatherNodeParts(node.declaration, parts);
}
} else if (t.isModuleSpecifier(node)) {
gatherNodeParts(node.local, parts);
} else if (t.isMemberExpression(node)) {
gatherNodeParts(node.object, parts);
gatherNodeParts(node.property, parts);
} else if (t.isIdentifier(node)) {
parts.push(node.name);
} else if (t.isLiteral(node)) {
parts.push(node.value);
} else if (t.isCallExpression(node)) {
gatherNodeParts(node.callee, parts);
} else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
for (const prop of node.properties) {
gatherNodeParts(prop.key || prop.argument, parts);
}
} 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");
break;
case "MemberExpression":
case "OptionalMemberExpression":
case "JSXMemberExpression":
gatherNodeParts(node.object, parts);
gatherNodeParts(node.property, parts);
break;
case "Identifier":
case "JSXIdentifier":
parts.push(node.name);
break;
case "CallExpression":
case "OptionalCallExpression":
case "NewExpression":
gatherNodeParts(node.callee, parts);
break;
case "ObjectExpression":
case "ObjectPattern":
for (const e of node.properties) {
gatherNodeParts(e, parts);
}
break;
case "SpreadElement":
case "RestElement":
gatherNodeParts(node.argument, parts);
break;
case "ObjectProperty":
case "ObjectMethod":
case "ClassProperty":
case "ClassMethod":
case "ClassPrivateProperty":
case "ClassPrivateMethod":
gatherNodeParts(node.key, parts);
break;
case "ThisExpression":
parts.push("this");
break;
case "Super":
parts.push("super");
break;
case "Import":
parts.push("import");
break;
case "DoExpression":
parts.push("do");
break;
case "YieldExpression":
parts.push("yield");
gatherNodeParts(node.argument, parts);
break;
case "AwaitExpression":
parts.push("await");
gatherNodeParts(node.argument, parts);
break;
case "AssignmentExpression":
gatherNodeParts(node.left, parts);
break;
case "VariableDeclarator":
gatherNodeParts(node.id, parts);
break;
case "FunctionExpression":
case "FunctionDeclaration":
case "ClassExpression":
case "ClassDeclaration":
gatherNodeParts(node.id, parts);
break;
case "PrivateName":
gatherNodeParts(node.id, parts);
break;
case "ParenthesizedExpression":
gatherNodeParts(node.expression, parts);
break;
case "UnaryExpression":
case "UpdateExpression":
gatherNodeParts(node.argument, parts);
break;
case "MetaProperty":
gatherNodeParts(node.meta, parts);
gatherNodeParts(node.property, parts);
break;
case "JSXElement":
gatherNodeParts(node.openingElement, parts);
break;
case "JSXOpeningElement":
parts.push(node.name);
break;
case "JSXFragment":
gatherNodeParts(node.openingFragment, parts);
break;
case "JSXOpeningFragment":
parts.push("Fragment");
break;
case "JSXNamespacedName":
gatherNodeParts(node.namespace, parts);
gatherNodeParts(node.name, parts);
break;
}
}
@@ -164,6 +264,28 @@ const collectorVisitor = {
path.scope.getBlockParent().registerDeclaration(bodyPath);
}
}
},
CatchClause(path) {
path.scope.registerBinding("let", path);
},
Function(path) {
if (path.isFunctionExpression() && path.has("id") && !path.get("id").node[t.NOT_LOCAL_BINDING]) {
path.scope.registerBinding("local", path.get("id"), path);
}
const params = path.get("params");
for (const param of params) {
path.scope.registerBinding("param", param);
}
},
ClassExpression(path) {
if (path.has("id") && !path.get("id").node[t.NOT_LOCAL_BINDING]) {
path.scope.registerBinding("local", path);
}
}
};
@@ -177,7 +299,7 @@ class Scope {
const cached = _cache.scope.get(node);
if (cached && cached.path === path) {
if ((cached == null ? void 0 : cached.path) === path) {
return cached;
}
@@ -187,11 +309,12 @@ class Scope {
this.block = node;
this.path = path;
this.labels = new Map();
this.inited = false;
}
get parent() {
const parent = this.path.findParent(p => p.isScope());
return parent && parent.scope;
return parent == null ? void 0 : parent.scope;
}
get parentBlock() {
@@ -221,7 +344,7 @@ class Scope {
generateUid(name = "temp") {
name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
let uid;
let i = 0;
let i = 1;
do {
uid = this._generateUid(name, i);
@@ -240,17 +363,7 @@ class Scope {
return `_${id}`;
}
generateUidBasedOnNode(parent, defaultName) {
let node = parent;
if (t.isAssignmentExpression(parent)) {
node = parent.left;
} else if (t.isVariableDeclarator(parent)) {
node = parent.id;
} else if (t.isObjectProperty(node) || t.isObjectMethod(node)) {
node = node.key;
}
generateUidBasedOnNode(node, defaultName) {
const parts = [];
gatherNodeParts(node, parts);
let id = parts.join("$");
@@ -258,8 +371,8 @@ class Scope {
return this.generateUid(id.slice(0, 20));
}
generateUidIdentifierBasedOnNode(parent, defaultName) {
return t.identifier(this.generateUidBasedOnNode(parent, defaultName));
generateUidIdentifierBasedOnNode(node, defaultName) {
return t.identifier(this.generateUidBasedOnNode(node, defaultName));
}
isStatic(node) {
@@ -324,7 +437,7 @@ class Scope {
}
dump() {
const sep = (0, _repeat.default)("-", 60);
const sep = "-".repeat(60);
console.log(sep);
let scope = this;
@@ -345,11 +458,11 @@ class Scope {
console.log(sep);
}
toArray(node, i) {
toArray(node, i, allowArrayLike) {
if (t.isIdentifier(node)) {
const binding = this.getBinding(node.name);
if (binding && binding.constant && binding.path.isGenericType("Array")) {
if ((binding == null ? void 0 : binding.constant) && binding.path.isGenericType("Array")) {
return node;
}
}
@@ -376,6 +489,11 @@ class Scope {
helperName = "toArray";
}
if (allowArrayLike) {
args.unshift(this.hub.addHelper(helperName));
helperName = "maybeArrayLike";
}
return t.callExpression(this.hub.addHelper(helperName), args);
}
@@ -451,6 +569,8 @@ class Scope {
const ids = path.getOuterBindingIdentifiers(true);
for (const name of Object.keys(ids)) {
parent.references[name] = true;
for (const id of ids[name]) {
const local = this.getOwnBinding(name);
@@ -459,8 +579,6 @@ class Scope {
this.checkBlockScopedCollisions(local, kind, name, id);
}
parent.references[name] = true;
if (local) {
this.registerConstantViolation(bindingPath);
} else {
@@ -500,13 +618,7 @@ class Scope {
}
hasReference(name) {
let scope = this;
do {
if (scope.references[name]) return true;
} while (scope = scope.parent);
return false;
return !!this.getProgramParent().references[name];
}
isPure(node, constantsOnly) {
@@ -541,7 +653,7 @@ class Scope {
}
return true;
} else if (t.isClassMethod(node)) {
} else if (t.isMethod(node)) {
if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
if (node.kind === "get" || node.kind === "set") return false;
return true;
@@ -586,7 +698,10 @@ class Scope {
}
init() {
if (!this.references) this.crawl();
if (!this.inited) {
this.inited = true;
this.crawl();
}
}
crawl() {
@@ -597,26 +712,11 @@ class Scope {
this.uids = Object.create(null);
this.data = Object.create(null);
if (path.isLoop()) {
for (const key of t.FOR_INIT_KEYS) {
const node = path.get(key);
if (node.isBlockScoped()) this.registerBinding(node.node.kind, node);
}
}
if (path.isFunctionExpression() && path.has("id")) {
if (!path.get("id").node[t.NOT_LOCAL_BINDING]) {
if (path.isFunction()) {
if (path.isFunctionExpression() && path.has("id") && !path.get("id").node[t.NOT_LOCAL_BINDING]) {
this.registerBinding("local", path.get("id"), path);
}
}
if (path.isClassExpression() && path.has("id")) {
if (!path.get("id").node[t.NOT_LOCAL_BINDING]) {
this.registerBinding("local", path);
}
}
if (path.isFunction()) {
const params = path.get("params");
for (const param of params) {
@@ -624,12 +724,8 @@ class Scope {
}
}
if (path.isCatchClause()) {
this.registerBinding("let", path);
}
const parent = this.getProgramParent();
if (parent.crawling) return;
const programParent = this.getProgramParent();
if (programParent.crawling) return;
const state = {
references: [],
constantViolations: [],
@@ -641,11 +737,9 @@ class Scope {
for (const path of state.assignments) {
const ids = path.getBindingIdentifiers();
let programParent;
for (const name of Object.keys(ids)) {
if (path.scope.getBinding(name)) continue;
programParent = programParent || path.scope.getProgramParent();
programParent.addGlobal(ids[name]);
}
@@ -658,7 +752,7 @@ class Scope {
if (binding) {
binding.reference(ref);
} else {
ref.scope.getProgramParent().addGlobal(ref.node);
programParent.addGlobal(ref.node);
}
}
@@ -742,7 +836,12 @@ class Scope {
let scope = this;
do {
(0, _defaults.default)(ids, scope.bindings);
for (const key of Object.keys(scope.bindings)) {
if (key in ids === false) {
ids[key] = scope.bindings[key];
}
}
scope = scope.parent;
} while (scope);
@@ -780,7 +879,9 @@ class Scope {
const binding = scope.getOwnBinding(name);
if (binding) {
if (previousPath && previousPath.isPattern() && previousPath.parentPath.isFunction() && binding.kind !== "param") {} else {
var _previousPath;
if (((_previousPath = previousPath) == null ? void 0 : _previousPath.isPattern()) && binding.kind !== "param") {} else {
return binding;
}
}
@@ -794,13 +895,14 @@ class Scope {
}
getBindingIdentifier(name) {
const info = this.getBinding(name);
return info && info.identifier;
var _this$getBinding;
return (_this$getBinding = this.getBinding(name)) == null ? void 0 : _this$getBinding.identifier;
}
getOwnBindingIdentifier(name) {
const binding = this.bindings[name];
return binding && binding.identifier;
return binding == null ? void 0 : binding.identifier;
}
hasOwnBinding(name) {
@@ -812,13 +914,15 @@ class Scope {
if (this.hasOwnBinding(name)) return true;
if (this.parentHasBinding(name, noGlobals)) return true;
if (this.hasUid(name)) return true;
if (!noGlobals && (0, _includes.default)(Scope.globals, name)) return true;
if (!noGlobals && (0, _includes.default)(Scope.contextVariables, name)) return true;
if (!noGlobals && Scope.globals.includes(name)) return true;
if (!noGlobals && Scope.contextVariables.includes(name)) return true;
return false;
}
parentHasBinding(name, noGlobals) {
return this.parent && this.parent.hasBinding(name, noGlobals);
var _this$parent;
return (_this$parent = this.parent) == null ? void 0 : _this$parent.hasBinding(name, noGlobals);
}
moveBindingTo(name, scope) {
@@ -836,12 +940,9 @@ class Scope {
}
removeBinding(name) {
const info = this.getBinding(name);
if (info) {
info.scope.removeOwnBinding(name);
}
var _this$getBinding2;
(_this$getBinding2 = this.getBinding(name)) == null ? void 0 : _this$getBinding2.scope.removeOwnBinding(name);
let scope = this;
do {

View File

@@ -32,7 +32,8 @@ const renameVisitor = {
}
},
"AssignmentExpression|Declaration"(path, state) {
"AssignmentExpression|Declaration|VariableDeclarator"(path, state) {
if (path.isVariableDeclaration()) return;
const ids = path.getOuterBindingIdentifiers();
for (const name in ids) {

View File

@@ -11,10 +11,6 @@ var virtualTypes = _interopRequireWildcard(require("./path/lib/virtual-types"));
var t = _interopRequireWildcard(require("@babel/types"));
var _clone = _interopRequireDefault(require("lodash/clone"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -85,7 +81,7 @@ function explode(visitor) {
if (existing) {
mergePair(existing, fns);
} else {
visitor[alias] = (0, _clone.default)(fns);
visitor[alias] = Object.assign({}, fns);
}
}
}
@@ -230,7 +226,7 @@ function shouldIgnoreKey(key) {
if (key[0] === "_") return true;
if (key === "enter" || key === "exit" || key === "shouldSkip") return true;
if (key === "blacklist" || key === "noScope" || key === "skipKeys") {
if (key === "denylist" || key === "noScope" || key === "skipKeys" || key === "blacklist") {
return true;
}