@putout/printer 12.14.0 → 12.15.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,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,10 @@ const {
|
|
|
13
14
|
isInsideLabel,
|
|
14
15
|
} = require('../../is');
|
|
15
16
|
|
|
17
|
+
const {
|
|
18
|
+
isFunctionDeclaration,
|
|
19
|
+
isAssignmentExpression,
|
|
20
|
+
} = types;
|
|
16
21
|
const not = (fn) => (...a) => !fn(...a);
|
|
17
22
|
|
|
18
23
|
const isBeforeElse = (path) => {
|
|
@@ -86,12 +91,24 @@ module.exports.ExpressionStatement = {
|
|
|
86
91
|
return;
|
|
87
92
|
|
|
88
93
|
if (notInsideReturn(path)) {
|
|
94
|
+
maybe.indent(isInsideAssignNextFunction(path));
|
|
89
95
|
print.newline();
|
|
90
96
|
maybe.markAfter(store(), path);
|
|
91
97
|
}
|
|
92
98
|
},
|
|
93
99
|
};
|
|
94
100
|
|
|
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
|
+
|
|
95
112
|
function isTopParentLast({parentPath}) {
|
|
96
113
|
if (!parentPath.isIfStatement())
|
|
97
114
|
return false;
|
|
@@ -131,3 +148,4 @@ function isStrictMode(path) {
|
|
|
131
148
|
|
|
132
149
|
return value === 'use strict';
|
|
133
150
|
}
|
|
151
|
+
|
package/package.json
CHANGED