New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@putout/printer

Package Overview
Dependencies
Maintainers
0
Versions
641
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 12.27.0 to 12.27.1

3

lib/tokenize/expressions/function/params.js

@@ -40,4 +40,5 @@ 'use strict';

const isLast = i === n;
const current = params[i];
traverse(params[i]);
traverse(current);

@@ -44,0 +45,0 @@ if (!isLast) {

@@ -6,12 +6,21 @@ 'use strict';

const isDecoratorHasLeadingComment = (path) => {
const [firstParam] = path.get('params');
const decorators = firstParam.get('decorators');
const isAllParamsHasLeadingComments = (path) => {
const params = path.get('params');
let commentsCount = 0;
let decoratorsCount = 0;
if (!decorators.length)
return false;
for (const param of params) {
const decorators = param.get('decorators');
if (!decorators.length)
continue;
const [firstDecorator] = decorators;
++decoratorsCount;
if (hasLeadingComment(firstDecorator))
++commentsCount;
}
const [firstDecorator] = decorators;
return hasLeadingComment(firstDecorator);
return commentsCount === decoratorsCount;
};

@@ -22,17 +31,23 @@

module.exports.printFunctionParams = (path, printer, semantics) => {
const {print} = printer;
const {params} = path.node;
const isNewline = params.filter(hasDecorators).length;
const printSpace = isNewline ? print.breakline : print.space;
const isAllHasComments = isAllParamsHasLeadingComments(path);
const printBeforeFirst = createPrint(path, {
const printSpace = createPrintSpace({
isNewline,
printer,
});
const printBeforeFirst = createPrintBeforeFirst(path, {
type: 'inc',
printer,
isNewline,
isAllHasComments,
});
const printAfterLast = createPrint(path, {
const printAfterLast = createPrintAfterLast({
type: 'dec',
printer,
isNewline,
isAllHasComments,
});

@@ -47,3 +62,3 @@

const createPrint = (path, {isNewline, printer, type}) => () => {
const createPrintBeforeFirst = (path, {isNewline, isAllHasComments, printer, type}) => () => {
if (!isNewline)

@@ -54,6 +69,32 @@ return;

if (!isDecoratorHasLeadingComment(path))
if (!isAllHasComments)
indent[type]();
print.breakline();
const [first] = path.get('params');
if (!first.node.decorators)
indent();
};
const createPrintAfterLast = ({isNewline, printer, isAllHasComments, type}) => () => {
if (!isNewline)
return;
const {indent, print} = printer;
if (!isAllHasComments)
indent[type]();
print.breakline();
};
const createPrintSpace = ({isNewline, printer}) => () => {
const {print} = printer;
if (!isNewline)
return print.space();
print.breakline();
};

@@ -43,4 +43,3 @@ 'use strict';

print('__parameter');
maybe.print(isNewline, ',');
maybe.print.breakline(decoratorsLength);
};
{
"name": "@putout/printer",
"version": "12.27.0",
"version": "12.27.1",
"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