@putout/printer
Advanced tools
Comparing version 6.8.2 to 6.9.0
@@ -16,2 +16,19 @@ 'use strict'; | ||
const isTrailingIsLeading = (path) => path.node.trailingComments === path.getNextSibling().node?.leadingComments; | ||
function isCommentOnNextLine(path) { | ||
const { | ||
loc, | ||
trailingComments, | ||
} = path.node; | ||
if (isTrailingIsLeading(path)) | ||
return false; | ||
const [comment] = trailingComments; | ||
const {line} = comment.loc.start; | ||
return line === loc.start.line + 1; | ||
} | ||
module.exports.parseTrailingComments = (path, {write, maybe}, semantics) => { | ||
@@ -33,6 +50,8 @@ if (!semantics.comments) | ||
const sameLine = isSameLine(path, loc); | ||
const commentOnNextLine = isCommentOnNextLine(path); | ||
if (type === 'CommentLine') { | ||
maybe.write.breakline(commentOnNextLine); | ||
maybe.write.space(sameLine); | ||
maybe.indent(!sameLine); | ||
maybe.indent(!sameLine && !commentOnNextLine); | ||
@@ -58,1 +77,2 @@ if (hasBody(path)) { | ||
}; | ||
'use strict'; | ||
const {hasTrailingComment} = require('../is'); | ||
module.exports.SpreadElement = (path, printer) => { | ||
@@ -5,0 +6,0 @@ const {print} = printer; |
{ | ||
"name": "@putout/printer", | ||
"version": "6.8.2", | ||
"version": "6.9.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
198258
4478