@putout/printer 1.128.1 → 1.130.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.06.03, v1.130.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 6b68c30 @putout/printer: get back assertion in ImportDeclarations
|
|
5
|
+
|
|
6
|
+
2023.06.02, v1.129.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 13e4315 @putout/printer: add support of ImportAttributes (https://babeljs.io/blog/2023/05/26/7.22.0#import-attributes-15536-15620)
|
|
10
|
+
|
|
1
11
|
2023.06.01, v1.128.1
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.ImportAttribute = (path, {print}) => {
|
|
4
|
+
print('{');
|
|
5
|
+
print.space();
|
|
6
|
+
print('__key');
|
|
7
|
+
print(':');
|
|
8
|
+
print.space();
|
|
9
|
+
print('__value');
|
|
10
|
+
print.space();
|
|
11
|
+
print('}');
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports.printAttributes = (path, {write, traverse}) => {
|
|
15
|
+
if (isAssertions(path))
|
|
16
|
+
printAssertions(path, {
|
|
17
|
+
write,
|
|
18
|
+
traverse,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const attributes = path.get('attributes');
|
|
22
|
+
|
|
23
|
+
if (!attributes.length)
|
|
24
|
+
return;
|
|
25
|
+
|
|
26
|
+
write(' with');
|
|
27
|
+
write.space();
|
|
28
|
+
|
|
29
|
+
for (const attr of attributes) {
|
|
30
|
+
traverse(attr);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const isAssertions = (path) => path.node.assertions;
|
|
35
|
+
|
|
36
|
+
function printAssertions(path, {write, traverse}) {
|
|
37
|
+
const attributes = path.get('assertions');
|
|
38
|
+
|
|
39
|
+
if (!attributes.length)
|
|
40
|
+
return;
|
|
41
|
+
|
|
42
|
+
write(' assert');
|
|
43
|
+
write.space();
|
|
44
|
+
|
|
45
|
+
for (const attr of attributes) {
|
|
46
|
+
traverse(attr);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -4,12 +4,18 @@ const {markAfter} = require('../../mark');
|
|
|
4
4
|
const {isLast} = require('../../is');
|
|
5
5
|
const {parseSpecifiers} = require('./parse-specifiers');
|
|
6
6
|
|
|
7
|
+
const {
|
|
8
|
+
printAttributes,
|
|
9
|
+
ImportAttribute,
|
|
10
|
+
} = require('./import-attribute');
|
|
11
|
+
|
|
7
12
|
const options = {
|
|
8
13
|
imports: {
|
|
9
14
|
maxOneLineSpecifiers: 2,
|
|
10
15
|
},
|
|
11
16
|
};
|
|
12
17
|
|
|
18
|
+
module.exports.ImportAttribute = ImportAttribute;
|
|
13
19
|
module.exports.ImportDeclaration = {
|
|
14
20
|
print(path, {print, maybe, write, traverse, indent}) {
|
|
15
21
|
const isType = path.node.importKind === 'type';
|
|
@@ -83,6 +89,10 @@ module.exports.ImportDeclaration = {
|
|
|
83
89
|
print.space();
|
|
84
90
|
|
|
85
91
|
print('__source');
|
|
92
|
+
printAttributes(path, {
|
|
93
|
+
write,
|
|
94
|
+
traverse,
|
|
95
|
+
});
|
|
86
96
|
print(';');
|
|
87
97
|
|
|
88
98
|
if (!isLast(path))
|
package/package.json
CHANGED