@putout/printer 14.2.0 → 14.3.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
+ 2025.03.28, v14.3.0
2
+
3
+ feature:
4
+ - 0252ed8 @putout/printer: ExpressionStatement: next is CallExpression with leading comment
5
+
1
6
  2025.03.28, v14.2.0
2
7
 
3
8
  feature:
@@ -95,4 +95,3 @@ function isInsideExportDefaultWithBody(path) {
95
95
 
96
96
  return path.node.body.body.length;
97
97
  }
98
-
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isNext,
5
6
  isLast,
@@ -15,6 +16,11 @@ const {
15
16
 
16
17
  const {isInsideAssignNextAssignFunction} = require('./is-inside-assign-next-assign-function');
17
18
 
19
+ const {
20
+ isCallExpression,
21
+ isExpressionStatement,
22
+ } = types;
23
+
18
24
  const not = (fn) => (...a) => !fn(...a);
19
25
 
20
26
  const isBeforeElse = (path) => {
@@ -69,7 +75,7 @@ module.exports.ExpressionStatement = {
69
75
 
70
76
  if (!insideReturn && shouldBreakline(path)) {
71
77
  print.newline();
72
- maybe.indent(isNext(path) && noTrailingComment(path));
78
+ maybe.indent(isNext(path) && noTrailingComment(path) || isNextCallWithLeadingComment(path));
73
79
  store(true);
74
80
  }
75
81
  },
@@ -141,3 +147,14 @@ function isStrictMode(path) {
141
147
 
142
148
  return value === 'use strict';
143
149
  }
150
+
151
+ function isNextCallWithLeadingComment(path) {
152
+ const nextPath = path.getNextSibling();
153
+
154
+ if (!isExpressionStatement(nextPath))
155
+ return false;
156
+
157
+ const {expression} = nextPath.node;
158
+
159
+ return isCallExpression(expression);
160
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "14.2.0",
3
+ "version": "14.3.0",
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",