@putout/printer 1.19.0 → 1.20.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
package/lib/tokenize/tokenize.js
CHANGED
|
@@ -234,11 +234,13 @@ const createPrint = (path, {traverse, write}) => (maybeLine) => {
|
|
|
234
234
|
};
|
|
235
235
|
|
|
236
236
|
const computePath = (path, maybeLine) => {
|
|
237
|
-
if (isString(maybeLine) && maybeLine.startsWith(GET))
|
|
237
|
+
if (isString(maybeLine) && maybeLine.startsWith(GET)) {
|
|
238
238
|
return get(path, maybeLine);
|
|
239
|
+
}
|
|
239
240
|
|
|
240
241
|
if (isObject(maybeLine))
|
|
241
242
|
return maybeLine;
|
|
242
243
|
|
|
243
244
|
return maybeLine;
|
|
244
245
|
};
|
|
246
|
+
|
|
@@ -35,7 +35,7 @@ module.exports = {
|
|
|
35
35
|
print('__typeAnnotation');
|
|
36
36
|
},
|
|
37
37
|
TSTypeAnnotation(path, {print}) {
|
|
38
|
-
if (
|
|
38
|
+
if (path.parentPath.isIdentifier()) {
|
|
39
39
|
print(':');
|
|
40
40
|
print.space();
|
|
41
41
|
}
|
|
@@ -55,4 +55,27 @@ module.exports = {
|
|
|
55
55
|
print('__typeAnnotation');
|
|
56
56
|
print(';');
|
|
57
57
|
},
|
|
58
|
+
TSTypeLiteral(path, {indent, traverse, write}) {
|
|
59
|
+
write('{');
|
|
60
|
+
write.newline();
|
|
61
|
+
indent.inc();
|
|
62
|
+
for (const member of path.get('members')) {
|
|
63
|
+
indent();
|
|
64
|
+
traverse(member);
|
|
65
|
+
write(';');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
write.newline();
|
|
69
|
+
indent.dec();
|
|
70
|
+
write('}');
|
|
71
|
+
},
|
|
72
|
+
TSPropertySignature(path, {print, maybe}) {
|
|
73
|
+
const {optional} = path.node;
|
|
74
|
+
print('__key');
|
|
75
|
+
maybe.print(optional, '?');
|
|
76
|
+
print(':');
|
|
77
|
+
print.space();
|
|
78
|
+
print('__typeAnnotation');
|
|
79
|
+
},
|
|
58
80
|
};
|
|
81
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"montag": "^1.0.0",
|
|
57
57
|
"nodemon": "^2.0.1",
|
|
58
58
|
"putout": "*",
|
|
59
|
-
"putout-plugin-
|
|
59
|
+
"putout-plugin-printer": "./rules",
|
|
60
60
|
"supertape": "^8.0.0",
|
|
61
61
|
"try-catch": "^3.0.0"
|
|
62
62
|
},
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const {assign} = Object;
|
|
4
|
-
|
|
5
|
-
module.exports.report = () => `Use print('__path') instead of path.get(__path)`;
|
|
6
|
-
|
|
7
|
-
module.exports.replace = () => ({
|
|
8
|
-
'print(path.get(__a))': ({__a}) => {
|
|
9
|
-
const {
|
|
10
|
-
raw,
|
|
11
|
-
value,
|
|
12
|
-
} = __a;
|
|
13
|
-
|
|
14
|
-
assign(__a, {
|
|
15
|
-
value: `__${value}`,
|
|
16
|
-
raw: raw.replace(value, `__${value}`),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return 'print(__a)';
|
|
20
|
-
},
|
|
21
|
-
});
|