Socket
Socket
Sign inDemoInstall

@babel/generator

Package Overview
Dependencies
Maintainers
4
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/generator - npm Package Compare versions

Comparing version 7.20.4 to 7.20.5

11

lib/index.js

@@ -68,2 +68,13 @@ "use strict";

}
const {
auxiliaryCommentBefore,
auxiliaryCommentAfter,
shouldPrintComment
} = format;
if (auxiliaryCommentBefore && !shouldPrintComment(auxiliaryCommentBefore)) {
format.auxiliaryCommentBefore = undefined;
}
if (auxiliaryCommentAfter && !shouldPrintComment(auxiliaryCommentAfter)) {
format.auxiliaryCommentAfter = undefined;
}
return format;

@@ -70,0 +81,0 @@ }

46

lib/printer.js

@@ -343,3 +343,6 @@ "use strict";

}
if (shouldPrintParens) this.tokenChar(40);
if (shouldPrintParens) {
this.tokenChar(40);
this._endsWithInnerRaw = false;
}
this._lastCommentLine = 0;

@@ -514,11 +517,16 @@ this._printLeadingComments(node, parent);

_shouldPrintComment(comment) {
if (comment.ignore) return 0;
if (this._printedComments.has(comment)) return 0;
if (this._noLineTerminator && (HAS_NEWLINE.test(comment.value) || HAS_BlOCK_COMMENT_END.test(comment.value))) {
return 2;
}
this._printedComments.add(comment);
if (!this.format.shouldPrintComment(comment.value)) {
return 0;
}
return 1;
}
_printComment(comment, skipNewLines) {
if (comment.ignore) return false;
if (this._printedComments.has(comment)) return false;
const noLineTerminator = this._noLineTerminator;
if (noLineTerminator && (HAS_NEWLINE.test(comment.value) || HAS_BlOCK_COMMENT_END.test(comment.value))) {
return true;
}
if (!this.format.shouldPrintComment(comment.value)) return false;
this._printedComments.add(comment);
const isBlockComment = comment.type === "CommentBlock";

@@ -565,3 +573,2 @@

}
return false;
}

@@ -579,4 +586,8 @@ _printComments(type, comments, node, parent, lineOffset = 0) {

const comment = comments[i];
const printed = this._printedComments.has(comment);
if (hasLoc && comment.loc && !printed) {
const shouldPrint = this._shouldPrintComment(comment);
if (shouldPrint === 2) {
hasLoc = false;
break;
}
if (hasLoc && comment.loc && shouldPrint === 1) {
const commentStartLine = comment.loc.start.line;

@@ -604,3 +615,3 @@ const commentEndLine = comment.loc.end.line;

maybeNewline(offset);
if (this._printComment(comment, 1)) break;
this._printComment(comment, 1);
if (i + 1 === len) {

@@ -618,3 +629,5 @@ maybeNewline(Math.min(1, nodeEndLine - lastLine));

hasLoc = false;
if (printed) continue;
if (shouldPrint !== 1) {
continue;
}
if (len === 1) {

@@ -628,5 +641,3 @@ const singleLine = comment.loc ? comment.loc.start.line === comment.loc.end.line : !HAS_NEWLINE.test(comment.value);

} else if (shouldSkipNewline && type === 2) {
if (this._printComment(comment, 1)) {
break;
}
this._printComment(comment, 1);
} else {

@@ -637,4 +648,3 @@ this._printComment(comment, 0);

const skippedDueToNewline = this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0);
if (skippedDueToNewline) break;
this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0);
} else {

@@ -641,0 +651,0 @@ this._printComment(comment, 0);

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

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

"dependencies": {
"@babel/types": "^7.20.2",
"@babel/types": "^7.20.5",
"@jridgewell/gen-mapping": "^0.3.2",

@@ -29,3 +29,3 @@ "jsesc": "^2.5.1"

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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