@putout/printer 1.113.1 → 1.115.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 +10 -0
- package/lib/tokenize/expressions/functions/arrow-function-expression.js +4 -15
- package/lib/tokenize/expressions/functions/class-method.js +5 -12
- package/lib/tokenize/expressions/functions/function-declaration.js +5 -11
- package/lib/tokenize/expressions/functions/function-expression.js +4 -12
- package/lib/tokenize/expressions/functions/object-method.js +4 -13
- package/lib/tokenize/expressions/functions/params.js +19 -0
- package/lib/tokenize/statements/index.js +2 -2
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {exists} = require('../../is');
|
|
4
|
+
const {printParams} = require('./params');
|
|
4
5
|
|
|
5
6
|
module.exports.ArrowFunctionExpression = {
|
|
6
7
|
condition({parentPath}) {
|
|
@@ -13,21 +14,10 @@ module.exports.ArrowFunctionExpression = {
|
|
|
13
14
|
const {async} = path.node;
|
|
14
15
|
|
|
15
16
|
maybe.print(async, 'async ');
|
|
16
|
-
print('(');
|
|
17
|
-
|
|
18
|
-
const params = path.get('params');
|
|
19
|
-
const n = params.length;
|
|
20
|
-
|
|
21
|
-
for (let i = 0; i < n; i++) {
|
|
22
|
-
print(params[i]);
|
|
23
|
-
|
|
24
|
-
if (i < n - 1) {
|
|
25
|
-
print(',');
|
|
26
|
-
print.space();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
17
|
|
|
30
|
-
|
|
18
|
+
printParams(path, {
|
|
19
|
+
print,
|
|
20
|
+
});
|
|
31
21
|
|
|
32
22
|
const returnType = path.get('returnType');
|
|
33
23
|
|
|
@@ -53,4 +43,3 @@ module.exports.ArrowFunctionExpression = {
|
|
|
53
43
|
write(')');
|
|
54
44
|
},
|
|
55
45
|
};
|
|
56
|
-
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {isNext} = require('../../is');
|
|
4
|
+
const {printParams} = require('./params');
|
|
4
5
|
|
|
5
6
|
const ClassMethod = {
|
|
6
7
|
print(path, {print, maybe}) {
|
|
@@ -18,19 +19,11 @@ const ClassMethod = {
|
|
|
18
19
|
print('__key');
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
printParams(path, {
|
|
23
|
+
print,
|
|
24
|
+
});
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
const n = params.length;
|
|
25
|
-
|
|
26
|
-
for (let i = 0; i < n; i++) {
|
|
27
|
-
print(params[i]);
|
|
28
|
-
|
|
29
|
-
if (i < n - 1)
|
|
30
|
-
print(', ');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
print(') ');
|
|
26
|
+
print.space();
|
|
34
27
|
print('__body');
|
|
35
28
|
},
|
|
36
29
|
afterSatisfy: () => [
|
|
@@ -7,6 +7,8 @@ const {
|
|
|
7
7
|
isNextParent,
|
|
8
8
|
} = require('../../is');
|
|
9
9
|
|
|
10
|
+
const {printParams} = require('./params');
|
|
11
|
+
|
|
10
12
|
module.exports.FunctionDeclaration = {
|
|
11
13
|
print(path, {print, maybe}) {
|
|
12
14
|
const {async} = path.node;
|
|
@@ -16,19 +18,11 @@ module.exports.FunctionDeclaration = {
|
|
|
16
18
|
print('function ');
|
|
17
19
|
print('__id');
|
|
18
20
|
print('__typeParameters');
|
|
19
|
-
print('(');
|
|
20
|
-
|
|
21
|
-
const params = path.get('params');
|
|
22
|
-
const n = params.length - 1;
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
print
|
|
26
|
-
|
|
27
|
-
if (i < n)
|
|
28
|
-
print(', ');
|
|
29
|
-
}
|
|
22
|
+
printParams(path, {
|
|
23
|
+
print,
|
|
24
|
+
});
|
|
30
25
|
|
|
31
|
-
print(')');
|
|
32
26
|
print.space();
|
|
33
27
|
print('__body');
|
|
34
28
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {exists} = require('../../is');
|
|
4
|
+
const {printParams} = require('./params');
|
|
4
5
|
|
|
5
6
|
module.exports.FunctionExpression = (path, {print, maybe, write, traverse}) => {
|
|
6
7
|
const {node} = path;
|
|
@@ -21,19 +22,10 @@ module.exports.FunctionExpression = (path, {print, maybe, write, traverse}) => {
|
|
|
21
22
|
traverse(id);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
printParams(path, {
|
|
26
|
+
print,
|
|
27
|
+
});
|
|
25
28
|
|
|
26
|
-
const params = path.get('params');
|
|
27
|
-
const n = params.length;
|
|
28
|
-
|
|
29
|
-
for (let i = 0; i < n; i++) {
|
|
30
|
-
print(params[i]);
|
|
31
|
-
|
|
32
|
-
if (i < n - 1)
|
|
33
|
-
print(', ');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
print(')');
|
|
37
29
|
print.space();
|
|
38
30
|
print('__body');
|
|
39
31
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {isNewlineBetweenSiblings} = require('../../is');
|
|
4
|
+
const {printParams} = require('./params');
|
|
4
5
|
|
|
5
6
|
module.exports.ObjectMethod = {
|
|
6
7
|
beforeIf(path) {
|
|
@@ -16,21 +17,11 @@ module.exports.ObjectMethod = {
|
|
|
16
17
|
print(`${kind} `);
|
|
17
18
|
|
|
18
19
|
print('__key');
|
|
19
|
-
print('(');
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
printParams(path, {
|
|
22
|
+
print,
|
|
23
|
+
});
|
|
23
24
|
|
|
24
|
-
for (let i = 0; i <= n; i++) {
|
|
25
|
-
print(params[i]);
|
|
26
|
-
|
|
27
|
-
if (i < n) {
|
|
28
|
-
print(',');
|
|
29
|
-
print.space();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
print(')');
|
|
34
25
|
print.space();
|
|
35
26
|
print('__body');
|
|
36
27
|
},
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.printParams = (path, {print}) => {
|
|
4
|
+
print('(');
|
|
5
|
+
|
|
6
|
+
const params = path.get('params');
|
|
7
|
+
const n = params.length;
|
|
8
|
+
|
|
9
|
+
for (let i = 0; i < n; i++) {
|
|
10
|
+
print(params[i]);
|
|
11
|
+
|
|
12
|
+
if (i < n - 1) {
|
|
13
|
+
print(',');
|
|
14
|
+
print.space();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
print(')');
|
|
19
|
+
};
|
package/package.json
CHANGED