@putout/printer 1.130.0 → 1.130.2
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 +10 -0
- package/lib/tokenize/statements/export-declaration/export-declaration.js +5 -0
- package/lib/tokenize/statements/import-declaration/import-attribute.js +20 -21
- package/lib/tokenize/statements/import-declaration/import-declaration.js +2 -2
- package/lib/tokenize/statements/variable-declaration/variable-declaration.js +4 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -4,6 +4,8 @@ const {
|
|
|
4
4
|
isNewlineBetweenSiblings,
|
|
5
5
|
exists,
|
|
6
6
|
isNext,
|
|
7
|
+
isLast,
|
|
8
|
+
|
|
7
9
|
} = require('../../is');
|
|
8
10
|
|
|
9
11
|
const {
|
|
@@ -107,6 +109,9 @@ module.exports.ExportNamedDeclaration = {
|
|
|
107
109
|
print('__declaration');
|
|
108
110
|
},
|
|
109
111
|
afterIf(path) {
|
|
112
|
+
if (isLast(path))
|
|
113
|
+
return false;
|
|
114
|
+
|
|
110
115
|
if (isDeclarationNewline(path))
|
|
111
116
|
return false;
|
|
112
117
|
|
|
@@ -1,48 +1,47 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports.ImportAttribute = (path, {print}) => {
|
|
4
|
-
print('{');
|
|
5
|
-
print.space();
|
|
6
4
|
print('__key');
|
|
7
5
|
print(':');
|
|
8
6
|
print.space();
|
|
9
7
|
print('__value');
|
|
10
|
-
print.space();
|
|
11
|
-
print('}');
|
|
12
8
|
};
|
|
13
9
|
|
|
14
|
-
module.exports.
|
|
10
|
+
module.exports.maybePrintAttributes = (path, {write, traverse}) => {
|
|
15
11
|
if (isAssertions(path))
|
|
16
|
-
|
|
12
|
+
return printAttributes(path, {
|
|
17
13
|
write,
|
|
18
14
|
traverse,
|
|
15
|
+
type: 'assertions',
|
|
16
|
+
keyword: 'assert',
|
|
19
17
|
});
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
write.space();
|
|
28
|
-
|
|
29
|
-
for (const attr of attributes) {
|
|
30
|
-
traverse(attr);
|
|
31
|
-
}
|
|
19
|
+
printAttributes(path, {
|
|
20
|
+
write,
|
|
21
|
+
traverse,
|
|
22
|
+
type: 'attributes',
|
|
23
|
+
keyword: 'with',
|
|
24
|
+
});
|
|
32
25
|
};
|
|
33
26
|
|
|
34
|
-
const isAssertions = (path) => path.node.assertions;
|
|
27
|
+
const isAssertions = (path) => path.node.assertions.length;
|
|
35
28
|
|
|
36
|
-
function
|
|
37
|
-
const attributes = path.get(
|
|
29
|
+
function printAttributes(path, {write, traverse, type, keyword}) {
|
|
30
|
+
const attributes = path.get(type);
|
|
38
31
|
|
|
39
32
|
if (!attributes.length)
|
|
40
33
|
return;
|
|
41
34
|
|
|
42
|
-
write(
|
|
35
|
+
write(` ${keyword}`);
|
|
36
|
+
write.space();
|
|
37
|
+
|
|
38
|
+
write('{');
|
|
43
39
|
write.space();
|
|
44
40
|
|
|
45
41
|
for (const attr of attributes) {
|
|
46
42
|
traverse(attr);
|
|
47
43
|
}
|
|
44
|
+
|
|
45
|
+
write.space();
|
|
46
|
+
write('}');
|
|
48
47
|
}
|
|
@@ -5,7 +5,7 @@ const {isLast} = require('../../is');
|
|
|
5
5
|
const {parseSpecifiers} = require('./parse-specifiers');
|
|
6
6
|
|
|
7
7
|
const {
|
|
8
|
-
|
|
8
|
+
maybePrintAttributes,
|
|
9
9
|
ImportAttribute,
|
|
10
10
|
} = require('./import-attribute');
|
|
11
11
|
|
|
@@ -89,7 +89,7 @@ module.exports.ImportDeclaration = {
|
|
|
89
89
|
print.space();
|
|
90
90
|
|
|
91
91
|
print('__source');
|
|
92
|
-
|
|
92
|
+
maybePrintAttributes(path, {
|
|
93
93
|
write,
|
|
94
94
|
traverse,
|
|
95
95
|
});
|
|
@@ -70,6 +70,10 @@ module.exports.VariableDeclaration = {
|
|
|
70
70
|
],
|
|
71
71
|
after(path, {maybe, store}) {
|
|
72
72
|
const wasNewline = store();
|
|
73
|
+
|
|
74
|
+
if (isLast(path.parentPath))
|
|
75
|
+
return false;
|
|
76
|
+
|
|
73
77
|
maybe.print.linebreak(wasNewline);
|
|
74
78
|
maybe.print.newline(!wasNewline);
|
|
75
79
|
maybe.markAfter(wasNewline, path);
|
package/package.json
CHANGED