@putout/printer 12.14.0 → 12.16.0
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.01.24, v12.16.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 974bf0e @putout/printer: ExpressionStatement: inside AssignemntExpression: after FunctionDeclaration
|
|
5
|
+
|
|
6
|
+
2025.01.24, v12.15.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 138144f @putout/printer: ExpressionStatement: indent: inside AssignmentExpression: after FunctionDeclaration
|
|
10
|
+
|
|
1
11
|
2025.01.24, v12.14.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -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,
|
|
@@ -13,6 +14,12 @@ const {
|
|
|
13
14
|
isInsideLabel,
|
|
14
15
|
} = require('../../is');
|
|
15
16
|
|
|
17
|
+
const {
|
|
18
|
+
isExpressionStatement,
|
|
19
|
+
isAssignmentExpression,
|
|
20
|
+
isFunction,
|
|
21
|
+
} = types;
|
|
22
|
+
|
|
16
23
|
const not = (fn) => (...a) => !fn(...a);
|
|
17
24
|
|
|
18
25
|
const isBeforeElse = (path) => {
|
|
@@ -75,7 +82,7 @@ module.exports.ExpressionStatement = {
|
|
|
75
82
|
|
|
76
83
|
return isBeforeElse(path);
|
|
77
84
|
},
|
|
78
|
-
after(path, {print, maybe, store}) {
|
|
85
|
+
after(path, {print, maybe, store, indent}) {
|
|
79
86
|
if (hasTrailingComment(path) && isLast(path) && isCoupleLines(path))
|
|
80
87
|
print.breakline();
|
|
81
88
|
|
|
@@ -86,12 +93,37 @@ module.exports.ExpressionStatement = {
|
|
|
86
93
|
return;
|
|
87
94
|
|
|
88
95
|
if (notInsideReturn(path)) {
|
|
96
|
+
if (isInsideAssignNextAssignFunction(path))
|
|
97
|
+
indent();
|
|
98
|
+
|
|
89
99
|
print.newline();
|
|
90
100
|
maybe.markAfter(store(), path);
|
|
91
101
|
}
|
|
92
102
|
},
|
|
93
103
|
};
|
|
94
104
|
|
|
105
|
+
const isInsideAssignNextAssignFunction = (path) => {
|
|
106
|
+
const {expression} = path.node;
|
|
107
|
+
|
|
108
|
+
if (!isAssignmentExpression(expression))
|
|
109
|
+
return false;
|
|
110
|
+
|
|
111
|
+
const next = path.getNextSibling();
|
|
112
|
+
|
|
113
|
+
if (!isExpressionStatement(next))
|
|
114
|
+
return false;
|
|
115
|
+
|
|
116
|
+
const {leadingComments} = next.node;
|
|
117
|
+
|
|
118
|
+
if (!leadingComments)
|
|
119
|
+
return false;
|
|
120
|
+
|
|
121
|
+
if (!isAssignmentExpression(next.node.expression))
|
|
122
|
+
return false;
|
|
123
|
+
|
|
124
|
+
return isFunction(next.node.expression.right);
|
|
125
|
+
};
|
|
126
|
+
|
|
95
127
|
function isTopParentLast({parentPath}) {
|
|
96
128
|
if (!parentPath.isIfStatement())
|
|
97
129
|
return false;
|
package/package.json
CHANGED