@putout/printer 12.15.0 → 12.17.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.17.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 9f5b1af @putout/printer: ExpressionStatement: inside AssignemntExpression: after FunctionDeclaration: indent
|
|
5
|
+
|
|
6
|
+
2025.01.24, v12.16.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 974bf0e @putout/printer: ExpressionStatement: inside AssignemntExpression: after FunctionDeclaration
|
|
10
|
+
|
|
1
11
|
2025.01.24, v12.15.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {types} = require('@putout/babel');
|
|
4
3
|
const {
|
|
5
4
|
isNext,
|
|
6
5
|
isLast,
|
|
@@ -14,10 +13,8 @@ const {
|
|
|
14
13
|
isInsideLabel,
|
|
15
14
|
} = require('../../is');
|
|
16
15
|
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
isAssignmentExpression,
|
|
20
|
-
} = types;
|
|
16
|
+
const {isInsideAssignNextAssignFunction} = require('./is-inside-assign-next-assign-function');
|
|
17
|
+
|
|
21
18
|
const not = (fn) => (...a) => !fn(...a);
|
|
22
19
|
|
|
23
20
|
const isBeforeElse = (path) => {
|
|
@@ -80,7 +77,7 @@ module.exports.ExpressionStatement = {
|
|
|
80
77
|
|
|
81
78
|
return isBeforeElse(path);
|
|
82
79
|
},
|
|
83
|
-
after(path, {print, maybe, store}) {
|
|
80
|
+
after(path, {print, maybe, store, indent}) {
|
|
84
81
|
if (hasTrailingComment(path) && isLast(path) && isCoupleLines(path))
|
|
85
82
|
print.breakline();
|
|
86
83
|
|
|
@@ -91,24 +88,15 @@ module.exports.ExpressionStatement = {
|
|
|
91
88
|
return;
|
|
92
89
|
|
|
93
90
|
if (notInsideReturn(path)) {
|
|
94
|
-
|
|
91
|
+
if (isInsideAssignNextAssignFunction(path))
|
|
92
|
+
indent();
|
|
93
|
+
|
|
95
94
|
print.newline();
|
|
96
95
|
maybe.markAfter(store(), path);
|
|
97
96
|
}
|
|
98
97
|
},
|
|
99
98
|
};
|
|
100
99
|
|
|
101
|
-
const isInsideAssignNextFunction = (path) => {
|
|
102
|
-
const {expression} = path.node;
|
|
103
|
-
|
|
104
|
-
if (!isAssignmentExpression(expression))
|
|
105
|
-
return false;
|
|
106
|
-
|
|
107
|
-
const next = path.getNextSibling();
|
|
108
|
-
|
|
109
|
-
return isFunctionDeclaration(next);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
100
|
function isTopParentLast({parentPath}) {
|
|
113
101
|
if (!parentPath.isIfStatement())
|
|
114
102
|
return false;
|
|
@@ -148,4 +136,3 @@ function isStrictMode(path) {
|
|
|
148
136
|
|
|
149
137
|
return value === 'use strict';
|
|
150
138
|
}
|
|
151
|
-
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
4
|
+
const {
|
|
5
|
+
isExpressionStatement,
|
|
6
|
+
isFunction,
|
|
7
|
+
isAssignmentExpression,
|
|
8
|
+
} = types;
|
|
9
|
+
|
|
10
|
+
module.exports.isInsideAssignNextAssignFunction = (path) => {
|
|
11
|
+
const {expression} = path.node;
|
|
12
|
+
|
|
13
|
+
if (!isAssignmentExpression(expression))
|
|
14
|
+
return false;
|
|
15
|
+
|
|
16
|
+
const next = path.getNextSibling();
|
|
17
|
+
|
|
18
|
+
if (isFunction(next) && next.node.leadingComments)
|
|
19
|
+
return true;
|
|
20
|
+
|
|
21
|
+
if (!isExpressionStatement(next))
|
|
22
|
+
return false;
|
|
23
|
+
|
|
24
|
+
const {leadingComments} = next.node;
|
|
25
|
+
|
|
26
|
+
if (!leadingComments)
|
|
27
|
+
return false;
|
|
28
|
+
|
|
29
|
+
if (!isAssignmentExpression(next.node.expression))
|
|
30
|
+
return false;
|
|
31
|
+
|
|
32
|
+
return isFunction(next.node.expression.right);
|
|
33
|
+
};
|
package/package.json
CHANGED