@putout/printer 2.45.0 → 2.46.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 +6 -0
- package/lib/tokenize/expressions/functions/function-declaration.js +1 -0
- package/lib/tokenize/literals/index.js +10 -0
- package/lib/tokenize/statements/block-statement/block-statement.js +20 -10
- package/lib/tokenize/statements/expression-statement.js +1 -0
- package/package.json +2 -1
package/ChangeLog
CHANGED
|
@@ -21,6 +21,15 @@ module.exports = {
|
|
|
21
21
|
|
|
22
22
|
write(raw || extra?.raw || value);
|
|
23
23
|
},
|
|
24
|
+
Directive(path, {print}) {
|
|
25
|
+
print('__value');
|
|
26
|
+
},
|
|
27
|
+
DirectiveLiteral(path, {write}) {
|
|
28
|
+
write.indent();
|
|
29
|
+
write(path.node.raw);
|
|
30
|
+
write(';');
|
|
31
|
+
write.newline();
|
|
32
|
+
},
|
|
24
33
|
BooleanLiteral(path, {write}) {
|
|
25
34
|
write(path.node.value);
|
|
26
35
|
},
|
|
@@ -62,3 +71,4 @@ module.exports = {
|
|
|
62
71
|
write('super');
|
|
63
72
|
},
|
|
64
73
|
};
|
|
74
|
+
|
|
@@ -16,41 +16,51 @@ const {markAfter} = require('../../mark');
|
|
|
16
16
|
const {parseComments} = require('../../comments');
|
|
17
17
|
const {insideIfWithNoBody} = require('./inside-if-with-no-body');
|
|
18
18
|
|
|
19
|
-
const isFirstStatement = (path) => path.
|
|
19
|
+
const isFirstStatement = (path) => path.node.body[0];
|
|
20
|
+
const isFirstDirective = (path) => path.node.directives?.[0];
|
|
20
21
|
const isMethodOrArrow = (path) => isArrowFunctionExpression(path) || isObjectMethod(path);
|
|
21
22
|
|
|
23
|
+
const getDirectives = (path) => !path.node.directives ? [] : path.get('directives');
|
|
24
|
+
|
|
25
|
+
module.exports._getDirectives = getDirectives;
|
|
26
|
+
|
|
22
27
|
module.exports.BlockStatement = {
|
|
23
|
-
print(path, {indent, maybe,
|
|
28
|
+
print(path, {indent, maybe, write, traverse}, semantics) {
|
|
24
29
|
const body = path.get('body');
|
|
30
|
+
const directives = getDirectives(path);
|
|
25
31
|
|
|
26
32
|
if (path.parentPath.isBlockStatement())
|
|
27
33
|
indent();
|
|
28
34
|
|
|
29
35
|
indent.inc();
|
|
30
|
-
|
|
36
|
+
write('{');
|
|
31
37
|
|
|
32
|
-
if (isFirstStatement(path))
|
|
33
|
-
|
|
38
|
+
if (isFirstStatement(path) || isFirstDirective(path))
|
|
39
|
+
write.newline();
|
|
40
|
+
|
|
41
|
+
for (const directive of directives) {
|
|
42
|
+
traverse(directive);
|
|
43
|
+
}
|
|
34
44
|
|
|
35
45
|
for (const element of body) {
|
|
36
|
-
|
|
46
|
+
traverse(element);
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
parseComments(path, {write}, semantics);
|
|
40
50
|
|
|
41
51
|
indent.dec();
|
|
42
52
|
maybe.indent(body.length);
|
|
43
|
-
|
|
53
|
+
write('}');
|
|
44
54
|
|
|
45
55
|
if (path.parentPath.isObjectMethod()) {
|
|
46
|
-
|
|
56
|
+
write(',');
|
|
47
57
|
}
|
|
48
58
|
},
|
|
49
59
|
afterIf(path) {
|
|
50
60
|
return shouldAddNewlineAfter(path);
|
|
51
61
|
},
|
|
52
|
-
after(path, {
|
|
53
|
-
|
|
62
|
+
after(path, {write}) {
|
|
63
|
+
write.newline();
|
|
54
64
|
markAfter(path.parentPath);
|
|
55
65
|
},
|
|
56
66
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.46.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"@babel/plugin-codemod-object-assign-to-object-spread": "^7.10.4",
|
|
51
51
|
"@putout/plugin-minify": "^1.8.0",
|
|
52
52
|
"@putout/plugin-printer": "^1.0.0",
|
|
53
|
+
"@putout/plugin-promises": "^10.0.0",
|
|
53
54
|
"@putout/plugin-react-hook-form": "^3.4.1",
|
|
54
55
|
"@putout/plugin-react-hooks": "^5.0.0",
|
|
55
56
|
"@putout/test": "^6.0.1",
|