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
603
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 8.3.0 to 8.4.0

9

lib/tokenize/expressions/array-expression/array-expression.js
'use strict';
const {types} = require('@putout/babel');
const {

@@ -22,8 +23,9 @@ isCoupleLines,

const {types} = require('@putout/babel');
const {
isObjectExpression,
isSpreadElement,
isStringLiteral,
} = types;
const isNextString = (path) => isStringLiteral(path.getNextSibling());
const isNextObject = (a) => a.getNextSibling().isObjectExpression();

@@ -102,5 +104,5 @@ const isPrevObject = (a) => a.getPrevSibling().isObjectExpression();

if (isInsideArray(path) && isStringAndArray(parentElements)) {
indent.dec();
maybe.indent.dec(!isNextString(path));
maybe.indent(elements.length && isNewLine);
indent.inc();
maybe.indent.inc(!isNextString(path));
} else if (!isArrayInsideArray(path) && !isObjectExpression(elements.at(-1))) {

@@ -133,1 +135,2 @@ maybe.indent(elements.length && isNewLine);

};
'use strict';
const {types} = require('@putout/babel');
const {isStringLiteral} = types;
const {isIndented} = require('../../is');
const {
isStringLiteral,
isArrayExpression,
} = types;
const isInsideArray = (path) => path.parentPath.isArrayExpression();

@@ -29,3 +32,10 @@

return path.parentPath.node.elements.length <= 3;
const parentElements = path.parentPath.node.elements;
const parentHasArrays = parentElements.filter(isArrayExpression).length;
const lastIsArray = !isArrayExpression(parentElements.at(-1));
if (parentHasArrays && lastIsArray)
return false;
return parentElements.length <= 3;
}

@@ -32,0 +42,0 @@

@@ -99,3 +99,3 @@ 'use strict';

if (isStringAndArray(elements))
if (isStringAndArray(elements) && elements.length < 3)
return ONE_LINE;

@@ -102,0 +102,0 @@

@@ -68,8 +68,3 @@ 'use strict';

module.exports.isIdentifierAndString = ([a, b]) => isIdentifier(a) && isStringLiteral(b);
module.exports.isStringAndArray = (array) => {
if (array.length > 2)
return false;
const [a, b] = array;
module.exports.isStringAndArray = ([a, b]) => {
if (!isStringLiteral(a))

@@ -76,0 +71,0 @@ return false;

{
"name": "@putout/printer",
"version": "8.3.0",
"version": "8.4.0",
"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