@putout/printer 14.3.5 → 14.3.6
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
|
@@ -13,6 +13,7 @@ const {isLooksLikeChain} = require('../expressions/member-expression/is-looks-li
|
|
|
13
13
|
const {
|
|
14
14
|
isDecorator,
|
|
15
15
|
isMemberExpression,
|
|
16
|
+
isExpressionStatement,
|
|
16
17
|
} = types;
|
|
17
18
|
|
|
18
19
|
const hasBody = (path) => {
|
|
@@ -136,8 +137,18 @@ module.exports.parseTrailingComments = (path, {write, maybe, indent}, semantics)
|
|
|
136
137
|
if (type === 'CommentBlock') {
|
|
137
138
|
maybe.write.space(sameLine);
|
|
138
139
|
maybe.indent(!sameLine);
|
|
140
|
+
maybe.print.breakline(isPrevCall(path));
|
|
139
141
|
write(`/*${value}*/`);
|
|
140
142
|
maybe.write.newline(!sameLine || !isFnParam(path) && isCoupleLines(path.parentPath));
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
};
|
|
146
|
+
|
|
147
|
+
function isPrevCall(path) {
|
|
148
|
+
const prev = path.getPrevSibling();
|
|
149
|
+
|
|
150
|
+
if (isExpressionStatement(prev))
|
|
151
|
+
return false;
|
|
152
|
+
|
|
153
|
+
return path.get('expression').isCallExpression();
|
|
154
|
+
}
|
|
@@ -19,6 +19,7 @@ const {isInsideAssignNextAssignFunction} = require('./is-inside-assign-next-assi
|
|
|
19
19
|
const {
|
|
20
20
|
isCallExpression,
|
|
21
21
|
isExpressionStatement,
|
|
22
|
+
isAssignmentExpression,
|
|
22
23
|
} = types;
|
|
23
24
|
|
|
24
25
|
const not = (fn) => (...a) => !fn(...a);
|
|
@@ -75,11 +76,7 @@ module.exports.ExpressionStatement = {
|
|
|
75
76
|
|
|
76
77
|
if (!insideReturn && shouldBreakline(path)) {
|
|
77
78
|
print.newline();
|
|
78
|
-
|
|
79
|
-
const condition = isNext(path)
|
|
80
|
-
&& noTrailingComment(path)
|
|
81
|
-
|| isNextCallWithLeadingComment(path)
|
|
82
|
-
|| isNextIf(path);
|
|
79
|
+
const condition = isNext(path) && noTrailingComment(path) || isNextToAssignmentCall(path);
|
|
83
80
|
|
|
84
81
|
if (condition)
|
|
85
82
|
indent();
|
|
@@ -156,7 +153,10 @@ function isStrictMode(path) {
|
|
|
156
153
|
return value === 'use strict';
|
|
157
154
|
}
|
|
158
155
|
|
|
159
|
-
function
|
|
156
|
+
function isNextToAssignmentCall(path) {
|
|
157
|
+
if (isAssignmentExpression(path.node.expression))
|
|
158
|
+
return false;
|
|
159
|
+
|
|
160
160
|
const nextPath = path.getNextSibling();
|
|
161
161
|
|
|
162
162
|
if (!isExpressionStatement(nextPath))
|
package/package.json
CHANGED