@putout/printer 14.3.4 → 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
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2025.03.28, v14.3.6
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- 7dbb77e @putout/printer: ExpressionStatement: AssignmentExpression and then CallEpression
|
|
5
|
+
|
|
6
|
+
2025.03.28, v14.3.5
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 79674c6 @putout/printer: VariableDeclaration: react-hooks
|
|
10
|
+
|
|
1
11
|
2025.03.28, v14.3.4
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -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))
|
|
@@ -96,6 +96,7 @@ module.exports.VariableDeclaration = {
|
|
|
96
96
|
}),
|
|
97
97
|
afterSatisfy: () => [
|
|
98
98
|
isNextIf,
|
|
99
|
+
isNextFn,
|
|
99
100
|
noNextParentBlock,
|
|
100
101
|
notLastCoupleLines,
|
|
101
102
|
isNextAssign,
|
|
@@ -193,6 +194,11 @@ const isNextIf = (path) => {
|
|
|
193
194
|
return nextPath.isIfStatement();
|
|
194
195
|
};
|
|
195
196
|
|
|
197
|
+
const isNextFn = (path) => {
|
|
198
|
+
const nextPath = path.getNextSibling();
|
|
199
|
+
return nextPath.isFunctionDeclaration();
|
|
200
|
+
};
|
|
201
|
+
|
|
196
202
|
const isNextAssign = (path) => {
|
|
197
203
|
const nextPath = path.getNextSibling();
|
|
198
204
|
|
package/package.json
CHANGED