feat: refactoring project
This commit is contained in:
42
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
42
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
@@ -3,12 +3,11 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ArrowFunctionExpression = ArrowFunctionExpression;
|
||||
exports.AssignmentExpression = AssignmentExpression;
|
||||
exports.Binary = Binary;
|
||||
exports.BinaryExpression = BinaryExpression;
|
||||
exports.ClassExpression = ClassExpression;
|
||||
exports.ConditionalExpression = ConditionalExpression;
|
||||
exports.ArrowFunctionExpression = exports.ConditionalExpression = ConditionalExpression;
|
||||
exports.DoExpression = DoExpression;
|
||||
exports.FunctionExpression = FunctionExpression;
|
||||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||||
@@ -33,13 +32,13 @@ const {
|
||||
isArrayTypeAnnotation,
|
||||
isBinaryExpression,
|
||||
isCallExpression,
|
||||
isExportDeclaration,
|
||||
isForOfStatement,
|
||||
isIndexedAccessType,
|
||||
isMemberExpression,
|
||||
isObjectPattern,
|
||||
isOptionalMemberExpression,
|
||||
isYieldExpression
|
||||
isYieldExpression,
|
||||
isStatement
|
||||
} = _t;
|
||||
const PRECEDENCE = new Map([["||", 0], ["??", 0], ["|>", 0], ["&&", 1], ["|", 2], ["^", 3], ["&", 4], ["==", 5], ["===", 5], ["!=", 5], ["!==", 5], ["<", 6], [">", 6], ["<=", 6], [">=", 6], ["in", 6], ["instanceof", 6], [">>", 7], ["<<", 7], [">>>", 7], ["+", 8], ["-", 8], ["*", 9], ["/", 9], ["%", 9], ["**", 10]]);
|
||||
function getBinaryPrecedence(node, nodeType) {
|
||||
@@ -66,14 +65,18 @@ function NullableTypeAnnotation(node, parent) {
|
||||
}
|
||||
function FunctionTypeAnnotation(node, parent, tokenContext) {
|
||||
const parentType = parent.type;
|
||||
return parentType === "UnionTypeAnnotation" || parentType === "IntersectionTypeAnnotation" || parentType === "ArrayTypeAnnotation" || Boolean(tokenContext & _index.TokenContext.arrowFlowReturnType);
|
||||
return (parentType === "UnionTypeAnnotation" || parentType === "IntersectionTypeAnnotation" || parentType === "ArrayTypeAnnotation" || Boolean(tokenContext & _index.TokenContext.arrowFlowReturnType)
|
||||
);
|
||||
}
|
||||
function UpdateExpression(node, parent) {
|
||||
return hasPostfixPart(node, parent) || isClassExtendsClause(node, parent);
|
||||
}
|
||||
function ObjectExpression(node, parent, tokenContext) {
|
||||
function needsParenBeforeExpressionBrace(tokenContext) {
|
||||
return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.arrowBody));
|
||||
}
|
||||
function ObjectExpression(node, parent, tokenContext) {
|
||||
return needsParenBeforeExpressionBrace(tokenContext);
|
||||
}
|
||||
function DoExpression(node, parent, tokenContext) {
|
||||
return !node.async && Boolean(tokenContext & _index.TokenContext.expressionStatement);
|
||||
}
|
||||
@@ -115,7 +118,7 @@ function TSAsExpression(node, parent) {
|
||||
}
|
||||
function TSUnionType(node, parent) {
|
||||
const parentType = parent.type;
|
||||
return parentType === "TSArrayType" || parentType === "TSOptionalType" || parentType === "TSIntersectionType" || parentType === "TSUnionType" || parentType === "TSRestType";
|
||||
return parentType === "TSArrayType" || parentType === "TSOptionalType" || parentType === "TSIntersectionType" || parentType === "TSRestType";
|
||||
}
|
||||
function TSInferType(node, parent) {
|
||||
const parentType = parent.type;
|
||||
@@ -130,10 +133,19 @@ function BinaryExpression(node, parent, tokenContext, inForStatementInit) {
|
||||
}
|
||||
function SequenceExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
if (parentType === "ForStatement" || parentType === "ThrowStatement" || parentType === "ReturnStatement" || parentType === "IfStatement" && parent.test === node || parentType === "WhileStatement" && parent.test === node || parentType === "ForInStatement" && parent.right === node || parentType === "SwitchStatement" && parent.discriminant === node || parentType === "ExpressionStatement" && parent.expression === node) {
|
||||
if (parentType === "SequenceExpression" || parentType === "ParenthesizedExpression" || parentType === "MemberExpression" && parent.property === node || parentType === "OptionalMemberExpression" && parent.property === node || parentType === "TemplateLiteral") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (parentType === "ClassDeclaration") {
|
||||
return true;
|
||||
}
|
||||
if (parentType === "ForOfStatement") {
|
||||
return parent.right === node;
|
||||
}
|
||||
if (parentType === "ExportDefaultDeclaration") {
|
||||
return true;
|
||||
}
|
||||
return !isStatement(parent);
|
||||
}
|
||||
function YieldExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
@@ -148,9 +160,6 @@ function UnaryLike(node, parent) {
|
||||
function FunctionExpression(node, parent, tokenContext) {
|
||||
return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault));
|
||||
}
|
||||
function ArrowFunctionExpression(node, parent) {
|
||||
return isExportDeclaration(parent) || ConditionalExpression(node, parent);
|
||||
}
|
||||
function ConditionalExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
if (parentType === "UnaryExpression" || parentType === "SpreadElement" || parentType === "BinaryExpression" || parentType === "LogicalExpression" || parentType === "ConditionalExpression" && parent.test === node || parentType === "AwaitExpression" || isTSTypeExpression(parentType)) {
|
||||
@@ -161,8 +170,8 @@ function ConditionalExpression(node, parent) {
|
||||
function OptionalMemberExpression(node, parent) {
|
||||
return isCallExpression(parent) && parent.callee === node || isMemberExpression(parent) && parent.object === node;
|
||||
}
|
||||
function AssignmentExpression(node, parent) {
|
||||
if (isObjectPattern(node.left)) {
|
||||
function AssignmentExpression(node, parent, tokenContext) {
|
||||
if (needsParenBeforeExpressionBrace(tokenContext) && isObjectPattern(node.left)) {
|
||||
return true;
|
||||
} else {
|
||||
return ConditionalExpression(node, parent);
|
||||
@@ -181,7 +190,7 @@ function LogicalExpression(node, parent) {
|
||||
return parent.operator !== "??";
|
||||
}
|
||||
}
|
||||
function Identifier(node, parent, tokenContext) {
|
||||
function Identifier(node, parent, tokenContext, _inForInit, getRawIdentifier) {
|
||||
var _node$extra;
|
||||
const parentType = parent.type;
|
||||
if ((_node$extra = node.extra) != null && _node$extra.parenthesized && parentType === "AssignmentExpression" && parent.left === node) {
|
||||
@@ -190,6 +199,9 @@ function Identifier(node, parent, tokenContext) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (getRawIdentifier && getRawIdentifier(node) !== node.name) {
|
||||
return false;
|
||||
}
|
||||
if (node.name === "let") {
|
||||
const isFollowedByBracket = isMemberExpression(parent, {
|
||||
object: node,
|
||||
|
||||
Reference in New Issue
Block a user