@putout/printer 1.92.4 → 1.94.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,3 +1,13 @@
|
|
|
1
|
+
2023.05.11, v1.94.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 2df6b15 @putout/printer: improve support of newline in TSInterfaceDeclaration
|
|
5
|
+
|
|
6
|
+
2023.05.11, v1.93.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 9822d55 @putout/printer: improve support computed property of ObjectPattern
|
|
10
|
+
|
|
1
11
|
2023.05.11, v1.92.4
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -8,55 +8,74 @@ const {
|
|
|
8
8
|
exists,
|
|
9
9
|
} = require('../is');
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const is = shouldAddNewline(path);
|
|
18
|
-
|
|
19
|
-
maybe.print(is, '\n');
|
|
20
|
-
|
|
21
|
-
for (const [i, property] of properties.entries()) {
|
|
22
|
-
if (property.isRestElement()) {
|
|
23
|
-
print(property);
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
11
|
+
const isOneParentProperty = ({parentPath}) => parentPath.parentPath.node.properties.length === 1;
|
|
12
|
+
|
|
13
|
+
module.exports.ObjectPattern = {
|
|
14
|
+
print(path, {indent, print, maybe}) {
|
|
15
|
+
indent.inc();
|
|
16
|
+
print('{');
|
|
26
17
|
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const {shorthand} = property.node;
|
|
31
|
-
const couple = isCoupleLines(valuePath) && !exists(property.getPrevSibling());
|
|
18
|
+
const properties = path.get('properties');
|
|
19
|
+
const n = properties.length - 1;
|
|
20
|
+
const is = shouldAddNewline(path);
|
|
32
21
|
|
|
33
|
-
maybe.
|
|
34
|
-
maybe.print.breakline(couple);
|
|
35
|
-
print(keyPath);
|
|
22
|
+
maybe.print(is, '\n');
|
|
36
23
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
24
|
+
for (const [i, property] of properties.entries()) {
|
|
25
|
+
if (property.isRestElement()) {
|
|
26
|
+
print(property);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
42
29
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
const valuePath = property.get('value');
|
|
31
|
+
const keyPath = property.get('key');
|
|
32
|
+
const isAssign = valuePath.isAssignmentPattern();
|
|
33
|
+
const {
|
|
34
|
+
shorthand,
|
|
35
|
+
computed,
|
|
36
|
+
} = property.node;
|
|
37
|
+
const couple = isCoupleLines(valuePath) && !exists(property.getPrevSibling());
|
|
50
38
|
|
|
51
|
-
|
|
39
|
+
maybe.indent(is);
|
|
40
|
+
maybe.print.breakline(couple);
|
|
41
|
+
|
|
42
|
+
maybe.print(computed, '[');
|
|
43
|
+
print(keyPath);
|
|
44
|
+
maybe.print(computed, ']');
|
|
45
|
+
|
|
46
|
+
if (!shorthand) {
|
|
47
|
+
print(': ');
|
|
48
|
+
print(valuePath);
|
|
49
|
+
} else if (isAssign) {
|
|
50
|
+
print(valuePath);
|
|
51
|
+
|
|
52
|
+
maybe.print(couple, ',');
|
|
53
|
+
maybe.print.newline(couple);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (is) {
|
|
57
|
+
print(',');
|
|
58
|
+
print.newline();
|
|
59
|
+
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
maybe.print(i < n, ', ');
|
|
52
64
|
}
|
|
53
65
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
indent.dec();
|
|
67
|
+
maybe.indent(is);
|
|
68
|
+
print('}');
|
|
69
|
+
},
|
|
70
|
+
afterIf(path) {
|
|
71
|
+
if (!path.parentPath.isObjectProperty())
|
|
72
|
+
return false;
|
|
73
|
+
|
|
74
|
+
return isOneParentProperty(path);
|
|
75
|
+
},
|
|
76
|
+
after(path, {print}) {
|
|
77
|
+
print.newline();
|
|
78
|
+
},
|
|
60
79
|
};
|
|
61
80
|
|
|
62
81
|
function checkLength(properties) {
|
|
@@ -12,6 +12,7 @@ const {
|
|
|
12
12
|
TSModuleDeclaration,
|
|
13
13
|
TSModuleBlock,
|
|
14
14
|
} = require('./ts-module-declaration');
|
|
15
|
+
const {TSInterfaceDeclaration} = require('./ts-interface-declaration');
|
|
15
16
|
|
|
16
17
|
module.exports = {
|
|
17
18
|
TSTypeLiteral,
|
|
@@ -84,11 +85,7 @@ module.exports = {
|
|
|
84
85
|
write(`${operator} `);
|
|
85
86
|
print('__typeAnnotation');
|
|
86
87
|
},
|
|
87
|
-
TSInterfaceDeclaration
|
|
88
|
-
print('interface ');
|
|
89
|
-
print('__id');
|
|
90
|
-
print('__body');
|
|
91
|
-
},
|
|
88
|
+
TSInterfaceDeclaration,
|
|
92
89
|
TSInterfaceBody(path, {traverse, write, indent}) {
|
|
93
90
|
write(' {');
|
|
94
91
|
write.newline();
|
package/package.json
CHANGED