Socket
Socket
Sign inDemoInstall

@babel/generator

Package Overview
Dependencies
10
Maintainers
4
Versions
166
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.19.5 to 7.19.6

39

lib/printer.js

@@ -12,4 +12,12 @@ "use strict";

var _t = require("@babel/types");
var generatorFunctions = require("./generators");
const {
isFunction,
isStatement,
isClassBody,
isTSInterfaceBody
} = _t;
const SCIENTIFIC_NOTATION = /e/i;

@@ -404,3 +412,3 @@ const ZERO_DECIMAL_INTEGER = /\.0+$/;

this._printLeadingComments(node);
this._printLeadingComments(node, parent);

@@ -413,7 +421,7 @@ const loc = nodeType === "Program" || nodeType === "File" ? null : node.loc;

this._printTrailingComments(node);
this._printTrailingComments(node, parent);
this._noLineTerminator = false;
} else {
this._printTrailingComments(node, trailingCommentsLineOffset);
this._printTrailingComments(node, parent, trailingCommentsLineOffset);
}

@@ -520,3 +528,3 @@

_printTrailingComments(node, lineOffset) {
_printTrailingComments(node, parent, lineOffset) {
const comments = this._getComments(false, node);

@@ -526,6 +534,6 @@

this._printComments(2, comments, node, lineOffset);
this._printComments(2, comments, node, parent, lineOffset);
}
_printLeadingComments(node) {
_printLeadingComments(node, parent) {
const comments = this._getComments(true, node);

@@ -535,3 +543,3 @@

this._printComments(0, comments, node);
this._printComments(0, comments, node, parent);
}

@@ -659,3 +667,3 @@

_printComments(type, comments, node, lineOffset = 0) {
_printComments(type, comments, node, parent, lineOffset = 0) {
{

@@ -719,4 +727,15 @@ const nodeLoc = node.loc;

if (len === 1) {
this._printComment(comment, 1);
} else if (type === 1 && !(node.type === "ObjectExpression" && node.properties.length > 1) && node.type !== "ClassBody") {
const singleLine = comment.loc ? comment.loc.start.line === comment.loc.end.line : !comment.value.includes("\n");
const shouldSkipNewline = singleLine && !isStatement(node) && !isClassBody(parent) && !isTSInterfaceBody(parent);
if (type === 0) {
this._printComment(comment, shouldSkipNewline && node.type !== "ObjectExpression" || singleLine && isFunction(parent, {
body: node
}) ? 1 : 0);
} else if (shouldSkipNewline && type === 2) {
this._printComment(comment, 1);
} else {
this._printComment(comment, 0);
}
} else if (type === 1 && !(node.type === "ObjectExpression" && node.properties.length > 1) && node.type !== "ClassBody" && node.type !== "TSInterfaceBody") {
this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0);

@@ -723,0 +742,0 @@ } else {

{
"name": "@babel/generator",
"version": "7.19.5",
"version": "7.19.6",
"description": "Turns an AST into code.",

@@ -28,3 +28,3 @@ "author": "The Babel Team (https://babel.dev/team)",

"@babel/helper-fixtures": "^7.19.4",
"@babel/parser": "^7.19.4",
"@babel/parser": "^7.19.6",
"@jridgewell/trace-mapping": "^0.3.8",

@@ -31,0 +31,0 @@ "@types/jsesc": "^2.5.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc