@putout/printer 1.91.0 → 1.92.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
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2023.05.10, v1.92.1
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- d6c9e2a @putout/printer: add support of comments inside ObjectExpression
|
|
5
|
+
|
|
6
|
+
2023.05.10, v1.92.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 2d623d5 @putout/printer: ExportNamespaceDeclaration: improve support
|
|
10
|
+
|
|
1
11
|
2023.05.10, v1.91.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -12,13 +12,14 @@ const {
|
|
|
12
12
|
} = require('../is');
|
|
13
13
|
|
|
14
14
|
const {isFunction} = require('@babel/types');
|
|
15
|
+
const {parseComments} = require('../comments');
|
|
15
16
|
|
|
16
17
|
const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
17
18
|
const isLogical = (path) => path.get('argument').isLogicalExpression();
|
|
18
19
|
const isValue = (path) => path.get('properties.0.value').node;
|
|
19
20
|
const isParentExpression = (path) => path.parentPath.isExpressionStatement();
|
|
20
21
|
|
|
21
|
-
module.exports.ObjectExpression = (path, {print, maybe, indent}) => {
|
|
22
|
+
module.exports.ObjectExpression = (path, {print, maybe, indent, write}) => {
|
|
22
23
|
indent.inc();
|
|
23
24
|
|
|
24
25
|
const properties = path.get('properties');
|
|
@@ -28,6 +29,7 @@ module.exports.ObjectExpression = (path, {print, maybe, indent}) => {
|
|
|
28
29
|
|
|
29
30
|
maybe.print(parens, '(');
|
|
30
31
|
print('{');
|
|
32
|
+
parseComments(path, {write});
|
|
31
33
|
maybe.print.newline(manyLines);
|
|
32
34
|
|
|
33
35
|
for (const property of properties) {
|
|
@@ -136,3 +138,4 @@ function isParens(path) {
|
|
|
136
138
|
|
|
137
139
|
return false;
|
|
138
140
|
}
|
|
141
|
+
|
|
@@ -9,9 +9,16 @@ const {
|
|
|
9
9
|
markAfter,
|
|
10
10
|
isMarkedAfter,
|
|
11
11
|
} = require('../../mark');
|
|
12
|
+
const {isExportNamespaceSpecifier} = require('@babel/types');
|
|
12
13
|
|
|
13
14
|
const isDeclarationNewline = (path) => isMarkedAfter(path.get('declaration'));
|
|
14
15
|
|
|
16
|
+
const options = {
|
|
17
|
+
exports: {
|
|
18
|
+
maxOneLineSpecifiers: 2,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
15
22
|
module.exports.ExportSpecifier = (path, {print}) => {
|
|
16
23
|
const {
|
|
17
24
|
local,
|
|
@@ -27,38 +34,53 @@ module.exports.ExportSpecifier = (path, {print}) => {
|
|
|
27
34
|
};
|
|
28
35
|
|
|
29
36
|
module.exports.ExportNamespaceSpecifier = (path, {print}) => {
|
|
30
|
-
print('
|
|
37
|
+
print('* as ');
|
|
31
38
|
print('__exported');
|
|
32
39
|
};
|
|
33
40
|
|
|
34
41
|
module.exports.ExportNamedDeclaration = {
|
|
35
|
-
print(path, {print, traverse, write, indent}) {
|
|
42
|
+
print(path, {print, traverse, write, indent, maybe}) {
|
|
36
43
|
const {exportKind} = path.node;
|
|
37
44
|
const specifiers = path.get('specifiers');
|
|
45
|
+
const {maxOneLineSpecifiers} = options.exports;
|
|
46
|
+
const source = path.get('source');
|
|
38
47
|
|
|
39
48
|
indent();
|
|
40
49
|
write('export ');
|
|
41
50
|
|
|
42
51
|
if (exportKind === 'type' && specifiers.length) {
|
|
43
|
-
print('type');
|
|
52
|
+
print('type ');
|
|
53
|
+
print(specifiers[0]);
|
|
54
|
+
print(' from ');
|
|
55
|
+
traverse(source);
|
|
56
|
+
print(';');
|
|
57
|
+
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (isExportNamespaceSpecifier(specifiers[0])) {
|
|
44
62
|
print(specifiers[0]);
|
|
45
63
|
print(' from ');
|
|
46
64
|
print('__source');
|
|
47
65
|
print(';');
|
|
66
|
+
print.newline();
|
|
48
67
|
|
|
49
68
|
return;
|
|
50
69
|
}
|
|
51
70
|
|
|
71
|
+
const n = specifiers.length;
|
|
72
|
+
const isNewline = !exists(source) || n > maxOneLineSpecifiers;
|
|
73
|
+
|
|
52
74
|
if (specifiers.length) {
|
|
53
75
|
write('{');
|
|
54
76
|
indent.inc();
|
|
55
|
-
write.newline();
|
|
77
|
+
maybe.write.newline(isNewline);
|
|
56
78
|
|
|
57
79
|
for (const spec of specifiers) {
|
|
58
|
-
indent();
|
|
80
|
+
maybe.indent(isNewline);
|
|
59
81
|
traverse(spec);
|
|
60
|
-
write(',');
|
|
61
|
-
write.newline();
|
|
82
|
+
maybe.write(isNewline, ',');
|
|
83
|
+
maybe.write.newline(isNewline);
|
|
62
84
|
}
|
|
63
85
|
|
|
64
86
|
indent.dec();
|
|
@@ -88,3 +110,4 @@ module.exports.ExportNamedDeclaration = {
|
|
|
88
110
|
markAfter(path);
|
|
89
111
|
},
|
|
90
112
|
};
|
|
113
|
+
|
package/package.json
CHANGED