@putout/printer
Advanced tools
Comparing version 8.27.0 to 8.28.0
@@ -27,4 +27,4 @@ import {types} from '@putout/babel'; | ||
declare namespace MaybeIndent { | ||
type inc = () => void; | ||
type dec = () => void; | ||
type inc = (condition: boolean) => void; | ||
type dec = (condition: boolean) => void; | ||
@@ -31,0 +31,0 @@ export { |
@@ -34,12 +34,22 @@ 'use strict'; | ||
const isInsideCall = ({parentPath}) => parentPath.isCallExpression(); | ||
function isInsideNestedArrayCall({parentPath}) { | ||
if (!parentPath.isArrayExpression()) | ||
return false; | ||
if (!parentPath.parentPath.isArrayExpression()) | ||
return false; | ||
return isInsideCall(parentPath.parentPath); | ||
} | ||
module.exports.ObjectExpression = (path, printer, semantics) => { | ||
const {trailingComma} = semantics; | ||
const { | ||
print, | ||
maybe, | ||
indent, | ||
} = printer; | ||
const {print, maybe} = printer; | ||
indent.inc(); | ||
const insideNestedArrayCall = isInsideNestedArrayCall(path); | ||
maybe.indent.inc(!insideNestedArrayCall); | ||
const properties = path.get('properties'); | ||
@@ -78,10 +88,7 @@ const {length} = properties; | ||
maybe.indent(manyLines && noLeadingComment(property)); | ||
print(property); | ||
if (property.isObjectMethod()) { | ||
print(property); | ||
if (property.isObjectMethod()) | ||
continue; | ||
} | ||
print(property); | ||
if (noTrailingComment(property) && !hasNextLeadingComment(property)) { | ||
@@ -93,6 +100,5 @@ maybe.print.newline(manyLines); | ||
indent.dec(); | ||
maybe.indent.dec(!insideNestedArrayCall); | ||
maybe.indent(manyLines && !insideNestedArrayCall); | ||
maybe.indent(manyLines); | ||
print('}'); | ||
@@ -135,3 +141,3 @@ maybe.print(parens, ')'); | ||
if (!length) | ||
return true; | ||
return ONE_LINE; | ||
@@ -138,0 +144,0 @@ if (notLastArgInsideCall(path)) |
@@ -12,4 +12,9 @@ 'use strict'; | ||
const isNextType = (a) => a.getNextSibling().isTSTypeAliasDeclaration(); | ||
const isNextExport = (a) => a.getNextSibling().isExportDeclaration(); | ||
module.exports.TSTypeAliasDeclaration = { | ||
beforeIf: (path) => !path.parentPath.isExportDeclaration(), | ||
before: (path, {indent}) => { | ||
indent(); | ||
}, | ||
print: maybeDeclare((path, {print, maybe, store}) => { | ||
@@ -44,3 +49,4 @@ const typeAnnotation = path.get('typeAnnotation'); | ||
}, | ||
after(path, {print}) { | ||
after(path, {print, maybe}) { | ||
maybe.indent(isNextExport(path)); | ||
print.newline(); | ||
@@ -50,1 +56,2 @@ markAfter(path); | ||
}; | ||
{ | ||
"name": "@putout/printer", | ||
"version": "8.27.0", | ||
"version": "8.28.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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
218002
4832