@putout/printer
Advanced tools
Comparing version 1.67.0 to 1.68.0
@@ -58,6 +58,7 @@ 'use strict'; | ||
const sameLine = isSameLine(path, loc); | ||
maybe.write.space(sameLine); | ||
maybe.indent(!sameLine); | ||
write(`//${value}`); | ||
maybe.write.newline(!sameLine); | ||
write.newline(); | ||
} | ||
@@ -64,0 +65,0 @@ } |
@@ -7,2 +7,4 @@ 'use strict'; | ||
isIf, | ||
noTrailingComment, | ||
} = require('../is'); | ||
@@ -50,3 +52,3 @@ | ||
print(property); | ||
maybe.print.newline(manyLines); | ||
maybe.print.newline(manyLines && noTrailingComment(property)); | ||
} | ||
@@ -53,0 +55,0 @@ |
@@ -88,1 +88,3 @@ 'use strict'; | ||
}; | ||
module.exports.noTrailingComment = (path) => !path.node.trailingComments; |
@@ -26,3 +26,5 @@ 'use strict'; | ||
const maybeProgram = (ast) => isProgram(ast) ? ast : Program([ExpressionStatement(ast)]); | ||
const maybeProgram = (ast) => isProgram(ast) ? ast : Program([ | ||
ExpressionStatement(ast), | ||
]); | ||
@@ -29,0 +31,0 @@ module.exports.maybeFile = (ast) => isFile(ast) ? ast : File(maybeProgram(ast)); |
'use strict'; | ||
const {isPrevBody} = require('../is'); | ||
const { | ||
isPrevBody, | ||
noTrailingComment, | ||
} = require('../is'); | ||
const {hasPrevNewline} = require('../mark'); | ||
const isBodyLength = ({parentPath}) => parentPath.node?.body?.length > 2; | ||
module.exports.ReturnStatement = (path, {indent, traverse, print}) => { | ||
if (!hasPrevNewline(path) && isBodyLength(path) || isPrevBody(path)) { | ||
module.exports.ReturnStatement = { | ||
beforeIf(path) { | ||
return !hasPrevNewline(path) && isBodyLength(path) || isPrevBody(path); | ||
}, | ||
before(path, {print}) { | ||
print.indent(); | ||
print.newline(); | ||
} | ||
indent(); | ||
print('return'); | ||
const argPath = path.get('argument'); | ||
if (argPath.node) { | ||
print(' '); | ||
traverse(argPath); | ||
} | ||
print(';'); | ||
print.newline(); | ||
}, | ||
print(path, {indent, traverse, print}) { | ||
indent(); | ||
print('return'); | ||
const argPath = path.get('argument'); | ||
if (argPath.node) { | ||
print(' '); | ||
traverse(argPath); | ||
} | ||
print(';'); | ||
}, | ||
afterSatisfy: () => [ | ||
noTrailingComment, | ||
], | ||
after(path, {print}) { | ||
print.newline(); | ||
}, | ||
}; |
@@ -28,2 +28,1 @@ 'use strict'; | ||
}; | ||
{ | ||
"name": "@putout/printer", | ||
"version": "1.67.0", | ||
"version": "1.68.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
97582
2623