@putout/printer 18.29.0 → 18.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2026.07.03, v18.30.0
2
+
3
+ feature:
4
+ - 3d01c7f0 @putout/printer: ExpressionStatement: comments: line: same
5
+
1
6
  2026.07.03, v18.29.0
2
7
 
3
8
  feature:
@@ -36,10 +36,8 @@ export const printTrailingCommentLine = (path, printer, semantics, {isSameLine,
36
36
 
37
37
  if (isSameLine)
38
38
  print.space();
39
- else if (!isNext(path) || isNextNotSimple(path))
40
- print.breakline();
41
39
  else
42
- print.indent();
40
+ print.breakline();
43
41
 
44
42
  printComment();
45
43
 
@@ -54,9 +52,7 @@ const isSimple = createTypeChecker([
54
52
  '+: node.expression -> BooleanLiteral',
55
53
  ]);
56
54
 
57
- const isNextNotSimple = createTypeChecker([
58
- ['+: -> !', callWithNext(isSimple)],
59
- ]);
55
+ export const isNextSimple = callWithNext(isSimple);
60
56
 
61
57
  export const printLeadingCommentBlock = (path, printer, semantics, {printComment}) => {
62
58
  const {indent} = printer;
@@ -16,6 +16,7 @@ import {
16
16
  printLeadingCommentBlock,
17
17
  printTrailingCommentLine,
18
18
  printTrailingCommentBlock,
19
+ isNextSimple,
19
20
  } from './comments.js';
20
21
 
21
22
  const {isIfStatement} = types;
@@ -29,7 +30,16 @@ const isNextToAssignmentCall = createTypeChecker([
29
30
  ['+', callWithNext(isCallInsideExpression)],
30
31
  ]);
31
32
 
33
+ const hasTrailingCommentOnTheSameLine = createTypeChecker([
34
+ ['-: node.trailingComments.length -> -'],
35
+ ['-: -> !', hasLeadingComment],
36
+ ['+', isSameLine],
37
+ ]);
38
+
32
39
  const isBreakline = createTypeChecker([
40
+ ['+: node.expression -> ArrayExpression'],
41
+ ['-', callWithNext(hasTrailingCommentOnTheSameLine)],
42
+ ['-', isNextSimple],
33
43
  ['+', isNewlineBetweenSiblings],
34
44
  ['+', callWithNext(isIfStatement)],
35
45
  ]);
@@ -97,4 +107,3 @@ export const ExpressionStatement = {
97
107
  export const isNewlineAfter = createTypeChecker([
98
108
  ['+: -> !', hasTrailingComment],
99
109
  ]);
100
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.29.0",
3
+ "version": "18.30.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",