@putout/printer
Advanced tools
Comparing version 1.10.0 to 1.11.0
'use strict'; | ||
const {entries} = Object; | ||
module.exports.NewExpression = (path, {indent, print, maybe}) => { | ||
@@ -15,3 +13,3 @@ indent(); | ||
for (const [i, arg] of entries(args)) { | ||
for (const [i, arg] of args.entries()) { | ||
print(arg); | ||
@@ -18,0 +16,0 @@ maybe.print(i < n, ', '); |
'use strict'; | ||
const {entries} = Object; | ||
const isForOf = (path) => path.parentPath?.parentPath?.parentPath?.isForOfStatement(); | ||
@@ -16,3 +15,3 @@ | ||
for (const [i, property] of entries(properties)) { | ||
for (const [i, property] of properties.entries()) { | ||
if (property.isRestElement()) { | ||
@@ -19,0 +18,0 @@ print(property); |
@@ -6,2 +6,4 @@ 'use strict'; | ||
isParentProgram, | ||
isLast, | ||
} = require('../is'); | ||
@@ -11,29 +13,33 @@ | ||
module.exports.BlockStatement = (path, {indent, maybe, print}) => { | ||
const body = path.get('body'); | ||
if (path.parentPath.isBlockStatement()) | ||
indent(); | ||
indent.inc(); | ||
print('{'); | ||
if (body.length > 1 || isFirstStatement(path)) | ||
module.exports.BlockStatement = { | ||
print(path, {indent, maybe, print}) { | ||
const body = path.get('body'); | ||
if (path.parentPath.isBlockStatement()) | ||
indent(); | ||
indent.inc(); | ||
print('{'); | ||
if (body.length > 1 || isFirstStatement(path)) | ||
print.newline(); | ||
for (const element of body) { | ||
print(element); | ||
} | ||
indent.dec(); | ||
maybe.indent(body.length); | ||
print('}'); | ||
if (path.parentPath.isObjectMethod()) { | ||
print(','); | ||
} | ||
}, | ||
afterIf(path) { | ||
return shouldAddNewlineAfter(path); | ||
}, | ||
after(path, {print}) { | ||
print.newline(); | ||
for (const element of body) { | ||
print(element); | ||
} | ||
indent.dec(); | ||
maybe.indent(body.length); | ||
print('}'); | ||
if (path.parentPath.isObjectMethod()) { | ||
print(','); | ||
} | ||
if (shouldAddNewlineAfter(path)) { | ||
print.newline(); | ||
} | ||
}, | ||
}; | ||
@@ -53,2 +59,5 @@ | ||
if (isLast(path)) | ||
return false; | ||
return true; | ||
@@ -55,0 +64,0 @@ } |
'use strict'; | ||
const {markAfter} = require('../mark'); | ||
const {entries} = Object; | ||
@@ -10,3 +9,3 @@ module.exports.ImportDeclaration = (path, {print, maybe}) => { | ||
for (const [index, spec] of entries(specifiers)) { | ||
for (const [index, spec] of specifiers.entries()) { | ||
if (spec.isImportDefaultSpecifier()) { | ||
@@ -18,3 +17,3 @@ print(spec.get('local')); | ||
if (spec.isImportSpecifier()) { | ||
maybe.print(Number(index), ', '); | ||
maybe.print(index, ', '); | ||
print('{'); | ||
@@ -21,0 +20,0 @@ print(spec.get('imported')); |
@@ -35,2 +35,3 @@ 'use strict'; | ||
path.get('body').forEach(print); | ||
print.newline(); | ||
}, | ||
@@ -37,0 +38,0 @@ SwitchStatement, |
{ | ||
"name": "@putout/printer", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"type": "commonjs", | ||
@@ -5,0 +5,0 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", |
@@ -63,3 +63,3 @@ # Printer [![NPM version][NPMIMGURL]][NPMURL] | ||
// returns | ||
'const {a /* [hello world] */= 5} = b;'; | ||
'const {a /* [hello world] */= 5} = b;\n'; | ||
``` | ||
@@ -66,0 +66,0 @@ |
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
54024
1547