@putout/printer 14.2.0 → 14.3.1

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,13 @@
1
+ 2025.03.28, v14.3.1
2
+
3
+ feature:
4
+ - 8ea46f3 @putout/printer: ExpressionStatement: after CallExpression: indent
5
+
6
+ 2025.03.28, v14.3.0
7
+
8
+ feature:
9
+ - 0252ed8 @putout/printer: ExpressionStatement: next is CallExpression with leading comment
10
+
1
11
  2025.03.28, v14.2.0
2
12
 
3
13
  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) => {
@@ -58,7 +64,7 @@ module.exports.ExpressionStatement = {
58
64
  before(path, {indent}) {
59
65
  indent();
60
66
  },
61
- print(path, {print, maybe, store}) {
67
+ print(path, {print, maybe, store, indent}) {
62
68
  const insideReturn = isInsideReturn(path);
63
69
 
64
70
  print('__expression');
@@ -69,7 +75,15 @@ module.exports.ExpressionStatement = {
69
75
 
70
76
  if (!insideReturn && shouldBreakline(path)) {
71
77
  print.newline();
72
- maybe.indent(isNext(path) && noTrailingComment(path));
78
+
79
+ const condition = isNext(path)
80
+ && noTrailingComment(path)
81
+ || isNextCallWithLeadingComment(path)
82
+ || isNextIf(path);
83
+
84
+ if (condition)
85
+ indent();
86
+
73
87
  store(true);
74
88
  }
75
89
  },
@@ -141,3 +155,15 @@ function isStrictMode(path) {
141
155
 
142
156
  return value === 'use strict';
143
157
  }
158
+
159
+ function isNextCallWithLeadingComment(path) {
160
+ const nextPath = path.getNextSibling();
161
+
162
+ if (!isExpressionStatement(nextPath))
163
+ return false;
164
+
165
+ const {expression} = nextPath.node;
166
+
167
+ return isCallExpression(expression);
168
+ }
169
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "14.2.0",
3
+ "version": "14.3.1",
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",