@putout/printer 14.0.0 → 14.0.1
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
|
@@ -5,6 +5,9 @@ const {markAfter} = require('../../mark');
|
|
|
5
5
|
const {isNext, isNextParent} = require('../../is');
|
|
6
6
|
const {printParams} = require('./params');
|
|
7
7
|
|
|
8
|
+
const not = (fn) => (...a) => !fn(...a);
|
|
9
|
+
const notInsideExportDefaultWithBody = not(isInsideExportDefaultWithBody);
|
|
10
|
+
|
|
8
11
|
const {
|
|
9
12
|
isAssignmentExpression,
|
|
10
13
|
isTSModuleBlock,
|
|
@@ -12,6 +15,7 @@ const {
|
|
|
12
15
|
isExportNamedDeclaration,
|
|
13
16
|
isExpressionStatement,
|
|
14
17
|
isFunctionDeclaration,
|
|
18
|
+
isExportDefaultDeclaration,
|
|
15
19
|
} = types;
|
|
16
20
|
|
|
17
21
|
const isInsideNamedExport = ({parentPath}) => isExportNamedDeclaration(parentPath);
|
|
@@ -50,11 +54,11 @@ module.exports.FunctionDeclaration = {
|
|
|
50
54
|
print('__body');
|
|
51
55
|
},
|
|
52
56
|
afterSatisfy: () => [isNext, isNextParent, isInsideBlockStatement],
|
|
53
|
-
after(path, {
|
|
57
|
+
after(path, {indent, maybe}) {
|
|
54
58
|
if (isNextAssign(path) || isNextFunction(path))
|
|
55
59
|
indent();
|
|
56
60
|
|
|
57
|
-
write.newline();
|
|
61
|
+
maybe.write.newline(notInsideExportDefaultWithBody(path));
|
|
58
62
|
markAfter(path);
|
|
59
63
|
},
|
|
60
64
|
};
|
|
@@ -84,3 +88,10 @@ function isInsideBlockStatement(path) {
|
|
|
84
88
|
|
|
85
89
|
return !path.node.body.body.length;
|
|
86
90
|
}
|
|
91
|
+
|
|
92
|
+
function isInsideExportDefaultWithBody(path) {
|
|
93
|
+
if (!isExportDefaultDeclaration(path.parentPath))
|
|
94
|
+
return false;
|
|
95
|
+
|
|
96
|
+
return path.node.body.body.length;
|
|
97
|
+
}
|
|
@@ -12,6 +12,7 @@ const {
|
|
|
12
12
|
const {
|
|
13
13
|
isBlockStatement,
|
|
14
14
|
isFunctionDeclaration,
|
|
15
|
+
isExpressionStatement,
|
|
15
16
|
} = types;
|
|
16
17
|
|
|
17
18
|
const isInside = ({parentPath}) => !parentPath.parentPath.isProgram();
|
|
@@ -103,7 +104,9 @@ module.exports.IfStatement = {
|
|
|
103
104
|
if (!isNext(path) && !consequent.isBlockStatement())
|
|
104
105
|
return;
|
|
105
106
|
|
|
106
|
-
|
|
107
|
+
const nextPath = path.parentPath.getNextSibling();
|
|
108
|
+
|
|
109
|
+
if (path === partOfAlternate && isInside(path) && !isExpressionStatement(nextPath))
|
|
107
110
|
print.newline();
|
|
108
111
|
|
|
109
112
|
if (isLastEmptyInsideBody(path))
|
package/package.json
CHANGED