Socket
Socket
Sign inDemoInstall

@babel/parser

Package Overview
Dependencies
Maintainers
6
Versions
204
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/parser - npm Package Compare versions

Comparing version 7.7.5 to 7.7.7

17

lib/parser/expression.js

@@ -26,6 +26,2 @@ "use strict";

const unwrapParenthesizedExpression = node => {
return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
};
class ExpressionParser extends _lval.default {

@@ -143,15 +139,2 @@ checkDuplicatedProto(prop, protoRef) {

this.checkLVal(left, undefined, undefined, "assignment expression");
const maybePattern = unwrapParenthesizedExpression(left);
let patternErrorMsg;
if (maybePattern.type === "ObjectPattern") {
patternErrorMsg = "`({a}) = 0` use `({a} = 0)`";
} else if (maybePattern.type === "ArrayPattern") {
patternErrorMsg = "`([a]) = 0` use `([a] = 0)`";
}
if (patternErrorMsg && (left.extra && left.extra.parenthesized || left.type === "ParenthesizedExpression")) {
this.raise(maybePattern.start, `You're trying to assign to a parenthesized expression, eg. instead of ${patternErrorMsg}`);
}
this.next();

@@ -158,0 +141,0 @@ node.right = this.parseMaybeAssign(noIn);

24

lib/parser/lval.js

@@ -16,7 +16,21 @@ "use strict";

const unwrapParenthesizedExpression = node => {
return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
};
class LValParser extends _node.NodeUtils {
toAssignable(node, isBinding, contextDescription) {
var _node$extra2;
var _node$extra3;
if (node) {
var _node$extra;
if (this.options.createParenthesizedExpressions && node.type === "ParenthesizedExpression" || ((_node$extra = node.extra) == null ? void 0 : _node$extra.parenthesized)) {
const parenthesized = unwrapParenthesizedExpression(node);
if (parenthesized.type !== "Identifier" && parenthesized.type !== "MemberExpression") {
this.raise(node.start, "Invalid parenthesized assignment pattern");
}
}
switch (node.type) {

@@ -33,3 +47,3 @@ case "Identifier":

for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
var _node$extra;
var _node$extra2;

@@ -40,3 +54,3 @@ const prop = node.properties[i];

if (isLast && prop.type === "RestElement" && ((_node$extra = node.extra) == null ? void 0 : _node$extra.trailingComma)) {
if (isLast && prop.type === "RestElement" && ((_node$extra2 = node.extra) == null ? void 0 : _node$extra2.trailingComma)) {
this.raiseRestNotLast(node.extra.trailingComma);

@@ -63,3 +77,3 @@ }

node.type = "ArrayPattern";
this.toAssignableList(node.elements, isBinding, contextDescription, (_node$extra2 = node.extra) == null ? void 0 : _node$extra2.trailingComma);
this.toAssignableList(node.elements, isBinding, contextDescription, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingComma);
break;

@@ -156,4 +170,2 @@

}
return exprList;
}

@@ -160,0 +172,0 @@

@@ -41,2 +41,9 @@ "use strict";

estreeParseBigIntLiteral(value) {
const bigInt = typeof BigInt !== "undefined" ? BigInt(value) : null;
const node = this.estreeParseLiteral(bigInt);
node.bigint = String(node.value || value);
return node;
}
estreeParseLiteral(value) {

@@ -165,5 +172,2 @@ return this.parseLiteral(value, "Literal");

switch (this.state.type) {
case _types.types.regexp:
return this.estreeParseRegExpLiteral(this.state.value);
case _types.types.num:

@@ -173,2 +177,8 @@ case _types.types.string:

case _types.types.regexp:
return this.estreeParseRegExpLiteral(this.state.value);
case _types.types.bigint:
return this.estreeParseBigIntLiteral(this.state.value);
case _types.types._null:

@@ -253,4 +263,25 @@ return this.estreeParseLiteral(null);

finishCallExpression(node, optional) {
super.finishCallExpression(node, optional);
if (node.callee.type === "Import") {
node.type = "ImportExpression";
node.source = node.arguments[0];
delete node.arguments;
delete node.callee;
}
return node;
}
toReferencedListDeep(exprList, isParenthesizedExpr) {
if (!exprList) {
return;
}
super.toReferencedListDeep(exprList, isParenthesizedExpr);
}
};
exports.default = _default;
{
"name": "@babel/parser",
"version": "7.7.5",
"version": "7.7.7",
"description": "A JavaScript parser",

@@ -39,3 +39,3 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>",

},
"gitHead": "d04508e510abc624b3e423ff334eff47f297502a"
"gitHead": "12da0941c898987ae30045a9da90ed5bf58ecaf9"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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