@putout/printer 14.3.6 → 14.3.7

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
+ 2025.03.29, v14.3.7
2
+
3
+ fix:
4
+ - a73ce65 @putout/printer: ExpressionStatement: comments
5
+
1
6
  2025.03.28, v14.3.6
2
7
 
3
8
  fix:
@@ -14,6 +14,7 @@ const {
14
14
  isDecorator,
15
15
  isMemberExpression,
16
16
  isExpressionStatement,
17
+ isCallExpression,
17
18
  } = types;
18
19
 
19
20
  const hasBody = (path) => {
@@ -150,5 +151,10 @@ function isPrevCall(path) {
150
151
  if (isExpressionStatement(prev))
151
152
  return false;
152
153
 
153
- return path.get('expression').isCallExpression();
154
+ const {expression} = path.node;
155
+
156
+ if (!isCallExpression(expression))
157
+ return false;
158
+
159
+ return !isCallExpression(expression.arguments[0]);
154
160
  }
@@ -15,6 +15,7 @@ const {
15
15
  } = require('../../is');
16
16
 
17
17
  const {isInsideAssignNextAssignFunction} = require('./is-inside-assign-next-assign-function');
18
+ const isCommentBlock = (a) => a?.type === 'CommentBlock';
18
19
 
19
20
  const {
20
21
  isCallExpression,
@@ -76,7 +77,11 @@ module.exports.ExpressionStatement = {
76
77
 
77
78
  if (!insideReturn && shouldBreakline(path)) {
78
79
  print.newline();
79
- const condition = isNext(path) && noTrailingComment(path) || isNextToAssignmentCall(path);
80
+
81
+ const condition = isNext(path)
82
+ && noTrailingComment(path)
83
+ || isNextToAssignmentCall(path)
84
+ || isNextStatementWithBlockComment(path);
80
85
 
81
86
  if (condition)
82
87
  indent();
@@ -166,3 +171,23 @@ function isNextToAssignmentCall(path) {
166
171
 
167
172
  return isCallExpression(expression);
168
173
  }
174
+
175
+ function isNextStatementWithBlockComment(path) {
176
+ const {expression} = path.node;
177
+
178
+ if (!isCallExpression(expression))
179
+ return false;
180
+
181
+ if (!isCallExpression(expression.arguments[0]))
182
+ return false;
183
+
184
+ return hasTrailingBlock(path);
185
+ }
186
+
187
+ function hasTrailingBlock(path) {
188
+ const {trailingComments} = path.node;
189
+ const [first] = trailingComments;
190
+
191
+ return isCommentBlock(first);
192
+ }
193
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "14.3.6",
3
+ "version": "14.3.7",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",