@putout/printer 12.15.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
|
@@ -15,9 +15,11 @@ const {
|
|
|
15
15
|
} = require('../../is');
|
|
16
16
|
|
|
17
17
|
const {
|
|
18
|
-
|
|
18
|
+
isExpressionStatement,
|
|
19
19
|
isAssignmentExpression,
|
|
20
|
+
isFunction,
|
|
20
21
|
} = types;
|
|
22
|
+
|
|
21
23
|
const not = (fn) => (...a) => !fn(...a);
|
|
22
24
|
|
|
23
25
|
const isBeforeElse = (path) => {
|
|
@@ -80,7 +82,7 @@ module.exports.ExpressionStatement = {
|
|
|
80
82
|
|
|
81
83
|
return isBeforeElse(path);
|
|
82
84
|
},
|
|
83
|
-
after(path, {print, maybe, store}) {
|
|
85
|
+
after(path, {print, maybe, store, indent}) {
|
|
84
86
|
if (hasTrailingComment(path) && isLast(path) && isCoupleLines(path))
|
|
85
87
|
print.breakline();
|
|
86
88
|
|
|
@@ -91,14 +93,16 @@ module.exports.ExpressionStatement = {
|
|
|
91
93
|
return;
|
|
92
94
|
|
|
93
95
|
if (notInsideReturn(path)) {
|
|
94
|
-
|
|
96
|
+
if (isInsideAssignNextAssignFunction(path))
|
|
97
|
+
indent();
|
|
98
|
+
|
|
95
99
|
print.newline();
|
|
96
100
|
maybe.markAfter(store(), path);
|
|
97
101
|
}
|
|
98
102
|
},
|
|
99
103
|
};
|
|
100
104
|
|
|
101
|
-
const
|
|
105
|
+
const isInsideAssignNextAssignFunction = (path) => {
|
|
102
106
|
const {expression} = path.node;
|
|
103
107
|
|
|
104
108
|
if (!isAssignmentExpression(expression))
|
|
@@ -106,7 +110,18 @@ const isInsideAssignNextFunction = (path) => {
|
|
|
106
110
|
|
|
107
111
|
const next = path.getNextSibling();
|
|
108
112
|
|
|
109
|
-
|
|
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);
|
|
110
125
|
};
|
|
111
126
|
|
|
112
127
|
function isTopParentLast({parentPath}) {
|
|
@@ -148,4 +163,3 @@ function isStrictMode(path) {
|
|
|
148
163
|
|
|
149
164
|
return value === 'use strict';
|
|
150
165
|
}
|
|
151
|
-
|
package/package.json
CHANGED