@putout/printer
Advanced tools
Comparing version 12.31.0 to 12.32.0
@@ -25,3 +25,6 @@ 'use strict'; | ||
const {isObjectAfterSimple} = require('./is-object-after-simple'); | ||
const { | ||
isObjectAfterSimple, | ||
isNextSimple, | ||
} = require('./is-object-after-simple'); | ||
@@ -34,2 +37,3 @@ const { | ||
isFunction, | ||
isCallExpression, | ||
} = types; | ||
@@ -65,14 +69,5 @@ | ||
const isNextSimple = (a) => { | ||
const next = a.getNextSibling(); | ||
if (next.isSpreadElement()) | ||
return true; | ||
return next.isIdentifier(); | ||
}; | ||
const isNextSimpleBetweenObjects = (a) => { | ||
const next = a.getNextSibling(); | ||
const is = next.isSpreadElement() || next.isIdentifier(); | ||
const is = next.isSpreadElement() || next.isIdentifier() || next.isCallExpression(); | ||
@@ -121,4 +116,3 @@ if (!is) | ||
if (indented) | ||
maybe.indent.inc(shouldIncreaseIndent); | ||
maybe.indent.inc(indented && shouldIncreaseIndent); | ||
@@ -157,4 +151,3 @@ const isNewLine = isMultiLine(path, { | ||
if (indented) | ||
maybe.indent.dec(shouldIncreaseIndent); | ||
maybe.indent.dec(indented && shouldIncreaseIndent); | ||
@@ -174,3 +167,3 @@ const parentElements = path.parentPath.get('elements'); | ||
if (isSimpleAndNotEmptyObject(elements) && !isSpreadElement(elements.at(-1))) { | ||
if (isSimpleAndNotEmptyObject(elements) && !isSpreadElement(elements.at(-1)) && !isCallExpression(elements.at(-1))) { | ||
print(','); | ||
@@ -205,3 +198,3 @@ print.breakline(); | ||
function isSimpleAfterObject(path) { | ||
if (!isSpreadElement(path) && !isIdentifier(path)) | ||
if (!isSpreadElement(path) && !isIdentifier(path) && !isCallExpression(path)) | ||
return; | ||
@@ -217,1 +210,2 @@ | ||
} | ||
@@ -22,1 +22,8 @@ 'use strict'; | ||
}; | ||
module.exports.isNextSimple = (a) => { | ||
const {type} = a.getNextSibling(); | ||
return SIMPLE_TYPES.includes(type); | ||
}; | ||
@@ -80,3 +80,4 @@ 'use strict'; | ||
module.exports.isSimpleAndNotEmptyObject = ([a, b]) => { | ||
module.exports.isSimpleAndNotEmptyObject = (elements) => { | ||
const [a, b] = elements; | ||
const simpleTypes = [ | ||
@@ -83,0 +84,0 @@ 'Identifier', |
{ | ||
"name": "@putout/printer", | ||
"version": "12.31.0", | ||
"version": "12.32.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
261330
5685