Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@putout/printer

Package Overview
Dependencies
Maintainers
1
Versions
604
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/printer - npm Package Compare versions

Comparing version 6.11.5 to 6.11.6

2

lib/tokenize/expressions/array-expression/newline.js

@@ -12,2 +12,3 @@ 'use strict';

};
const isLotsOfElementsFirstNotObject = (path) => {

@@ -295,2 +296,1 @@ const {elements} = path.node;

};

@@ -8,2 +8,4 @@ 'use strict';

exists,
satisfy,
} = require('../../is');

@@ -16,2 +18,4 @@

isExportDeclaration,
isDoWhileStatement,
isBlockStatement,
} = require('@putout/babel').types;

@@ -82,31 +86,58 @@

function shouldAddNewlineAfter(path) {
const {parentPath} = path;
if (parentPath.isDoWhileStatement())
const isTopLevelWithNoNext = (path) => {
if (isNext(path))
return false;
if (parentPath.isBlockStatement())
return true;
return !isNext(path.parentPath) && isParentProgram(path.parentPath);
};
const isInsideIfWithoutElseInsideFn = (path) => {
return parentIfWithoutElse(path) && path.find(isMethodOrArrow);
};
const isEmptyBodyNoNext = (path) => {
const {parentPath} = path;
return parentPath.isStatement() && !path.node.body.length && !isNext(parentPath);
};
const isLooksLikeInsideFn = ({parentPath}) => {
return /FunctionExpression/.test(parentPath.type);
};
const NEWLINE = true;
const NO_NEWLINE = false;
const isInsideDoWhile = ({parentPath}) => isDoWhileStatement(parentPath);
const isInsideBlock = ({parentPath}) => isBlockStatement(parentPath);
const isNoNewline = satisfy([
isInsideDoWhile,
isTopLevelWithNoNext,
insideIfWithNoBody,
]);
function shouldAddNewlineAfter(path) {
if (isInsideBlock(path))
return NEWLINE;
if (!isNext(path) && !isNext(path.parentPath) && isParentProgram(path.parentPath))
return false;
if (isNoNewline(path))
return NO_NEWLINE;
if (insideIfWithNoBody(path))
return false;
if (isInsideIfWithoutElseInsideFn(path))
return NEWLINE;
if (parentIfWithoutElse(path) && path.find(isMethodOrArrow))
return true;
if (isEmptyBodyNoNext(path))
return NO_NEWLINE;
if (parentPath.isStatement() && !path.node.body.length && !isNext(parentPath))
return false;
if (isTry(path))
return NO_NEWLINE;
if (isTry(path) || /FunctionExpression/.test(path.parentPath.type))
return false;
if (isLooksLikeInsideFn(path))
return NO_NEWLINE;
if (isLast(path))
return false;
return NO_NEWLINE;
if (isExportFunction(path))
return false;
return NO_NEWLINE;

@@ -113,0 +144,0 @@ return !isNextIfAlternate(path);

{
"name": "@putout/printer",
"version": "6.11.5",
"version": "6.11.6",
"type": "commonjs",

@@ -5,0 +5,0 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",

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