@putout/printer 11.9.0 → 11.10.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
|
@@ -89,7 +89,11 @@ module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics)
|
|
|
89
89
|
const insideFn = (path.parentPath.isFunction() || path.parentPath.isTSDeclareMethod()) && !path.isTSTypeParameterDeclaration();
|
|
90
90
|
|
|
91
91
|
const propIs = isProperty(path);
|
|
92
|
-
const isIndent = isFirst(path)
|
|
92
|
+
const isIndent = isFirst(path)
|
|
93
|
+
|| !looksLikeSwitchCase
|
|
94
|
+
&& !path.isClassMethod()
|
|
95
|
+
&& !insideFn
|
|
96
|
+
&& !propIs;
|
|
93
97
|
|
|
94
98
|
for (const {type, value} of leadingComments) {
|
|
95
99
|
maybe.indent(isIndent);
|
|
@@ -35,14 +35,14 @@ module.exports.ExportNamespaceSpecifier = (path, {print}) => {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
module.exports.ExportNamedDeclaration = {
|
|
38
|
-
print(path, {print, traverse,
|
|
38
|
+
print(path, {print, traverse, indent, maybe}) {
|
|
39
39
|
const {exportKind} = path.node;
|
|
40
40
|
const specifiers = path.get('specifiers');
|
|
41
41
|
const {maxOneLineSpecifiers} = options.exports;
|
|
42
42
|
const source = path.get('source');
|
|
43
43
|
|
|
44
44
|
indent();
|
|
45
|
-
|
|
45
|
+
print('export');
|
|
46
46
|
|
|
47
47
|
if (exportKind === 'type' && specifiers.length)
|
|
48
48
|
print(' type');
|
|
@@ -61,39 +61,43 @@ module.exports.ExportNamedDeclaration = {
|
|
|
61
61
|
const n = specifiers.length;
|
|
62
62
|
const isNewline = !exists(source) || n > maxOneLineSpecifiers;
|
|
63
63
|
|
|
64
|
-
if (specifiers.
|
|
64
|
+
if (specifiers && !path.node.declaration) {
|
|
65
65
|
print.space();
|
|
66
|
-
|
|
67
|
-
indent.inc();
|
|
68
|
-
maybe.write.newline(isNewline);
|
|
66
|
+
print('{');
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
maybe.write(isType, 'type ');
|
|
76
|
-
traverse(spec);
|
|
68
|
+
if (specifiers.length) {
|
|
69
|
+
indent.inc();
|
|
70
|
+
maybe.print.newline(isNewline);
|
|
71
|
+
|
|
72
|
+
const lastIndex = n - 1;
|
|
77
73
|
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
for (const [i, spec] of specifiers.entries()) {
|
|
75
|
+
const isType = spec.node.exportKind === 'type';
|
|
76
|
+
maybe.indent(isNewline);
|
|
77
|
+
maybe.print(isType, 'type ');
|
|
78
|
+
traverse(spec);
|
|
79
|
+
|
|
80
|
+
if (i < lastIndex && !isNewline)
|
|
81
|
+
print(', ');
|
|
82
|
+
|
|
83
|
+
maybe.print(isNewline, ',');
|
|
84
|
+
maybe.print.newline(isNewline);
|
|
85
|
+
}
|
|
80
86
|
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
indent.dec();
|
|
88
|
+
indent();
|
|
83
89
|
}
|
|
84
90
|
|
|
85
|
-
|
|
86
|
-
indent();
|
|
87
|
-
write('}');
|
|
91
|
+
print('}');
|
|
88
92
|
const source = path.get('source');
|
|
89
93
|
|
|
90
94
|
if (exists(source)) {
|
|
91
|
-
|
|
95
|
+
print(' from ');
|
|
92
96
|
traverse(source);
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
maybe.
|
|
99
|
+
print(';');
|
|
100
|
+
maybe.print.newline(isNext(path) || isInsideNamespace(path));
|
|
97
101
|
|
|
98
102
|
return;
|
|
99
103
|
}
|
|
@@ -115,3 +119,4 @@ module.exports.ExportNamedDeclaration = {
|
|
|
115
119
|
markAfter(path);
|
|
116
120
|
},
|
|
117
121
|
};
|
|
122
|
+
|
package/package.json
CHANGED