@putout/printer 14.3.5 → 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,13 @@
|
|
|
1
|
+
2025.03.29, v14.3.7
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- a73ce65 @putout/printer: ExpressionStatement: comments
|
|
5
|
+
|
|
6
|
+
2025.03.28, v14.3.6
|
|
7
|
+
|
|
8
|
+
fix:
|
|
9
|
+
- 7dbb77e @putout/printer: ExpressionStatement: AssignmentExpression and then CallEpression
|
|
10
|
+
|
|
1
11
|
2025.03.28, v14.3.5
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -13,6 +13,8 @@ const {isLooksLikeChain} = require('../expressions/member-expression/is-looks-li
|
|
|
13
13
|
const {
|
|
14
14
|
isDecorator,
|
|
15
15
|
isMemberExpression,
|
|
16
|
+
isExpressionStatement,
|
|
17
|
+
isCallExpression,
|
|
16
18
|
} = types;
|
|
17
19
|
|
|
18
20
|
const hasBody = (path) => {
|
|
@@ -136,8 +138,23 @@ module.exports.parseTrailingComments = (path, {write, maybe, indent}, semantics)
|
|
|
136
138
|
if (type === 'CommentBlock') {
|
|
137
139
|
maybe.write.space(sameLine);
|
|
138
140
|
maybe.indent(!sameLine);
|
|
141
|
+
maybe.print.breakline(isPrevCall(path));
|
|
139
142
|
write(`/*${value}*/`);
|
|
140
143
|
maybe.write.newline(!sameLine || !isFnParam(path) && isCoupleLines(path.parentPath));
|
|
141
144
|
}
|
|
142
145
|
}
|
|
143
146
|
};
|
|
147
|
+
|
|
148
|
+
function isPrevCall(path) {
|
|
149
|
+
const prev = path.getPrevSibling();
|
|
150
|
+
|
|
151
|
+
if (isExpressionStatement(prev))
|
|
152
|
+
return false;
|
|
153
|
+
|
|
154
|
+
const {expression} = path.node;
|
|
155
|
+
|
|
156
|
+
if (!isCallExpression(expression))
|
|
157
|
+
return false;
|
|
158
|
+
|
|
159
|
+
return !isCallExpression(expression.arguments[0]);
|
|
160
|
+
}
|
|
@@ -15,10 +15,12 @@ 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,
|
|
21
22
|
isExpressionStatement,
|
|
23
|
+
isAssignmentExpression,
|
|
22
24
|
} = types;
|
|
23
25
|
|
|
24
26
|
const not = (fn) => (...a) => !fn(...a);
|
|
@@ -78,8 +80,8 @@ module.exports.ExpressionStatement = {
|
|
|
78
80
|
|
|
79
81
|
const condition = isNext(path)
|
|
80
82
|
&& noTrailingComment(path)
|
|
81
|
-
||
|
|
82
|
-
||
|
|
83
|
+
|| isNextToAssignmentCall(path)
|
|
84
|
+
|| isNextStatementWithBlockComment(path);
|
|
83
85
|
|
|
84
86
|
if (condition)
|
|
85
87
|
indent();
|
|
@@ -156,7 +158,10 @@ function isStrictMode(path) {
|
|
|
156
158
|
return value === 'use strict';
|
|
157
159
|
}
|
|
158
160
|
|
|
159
|
-
function
|
|
161
|
+
function isNextToAssignmentCall(path) {
|
|
162
|
+
if (isAssignmentExpression(path.node.expression))
|
|
163
|
+
return false;
|
|
164
|
+
|
|
160
165
|
const nextPath = path.getNextSibling();
|
|
161
166
|
|
|
162
167
|
if (!isExpressionStatement(nextPath))
|
|
@@ -166,3 +171,23 @@ function isNextCallWithLeadingComment(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