@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
|
@@ -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
|
-
|
|
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
|
-
|
|
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