@putout/printer 4.2.0 → 5.1.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,20 @@
|
|
|
1
|
+
2023.09.19, v5.1.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 8cea880 package: eslint-plugin-putout v20.0.0
|
|
5
|
+
- 7ae8762 @putout/printer: ObjectExpression used as argument of CallExpression with MemberExpression chain used as callee
|
|
6
|
+
|
|
7
|
+
2023.09.18, v5.0.0
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- 9ad0e3c package: putout v32.0.4
|
|
11
|
+
- b8e15fc package: estree-to-babel v7.0.0
|
|
12
|
+
- ebcf3aa package: @putout/plugin-react-hook-form v4.0.0
|
|
13
|
+
- efbf8e8 package: @putout/plugin-promises v13.0.0
|
|
14
|
+
- 7ebee8a package: @putout/operate v11.0.0
|
|
15
|
+
- a40cb80 package: @putout/compare v13.0.0
|
|
16
|
+
- 84c933d @putout/printer: TSMappedType: nameType
|
|
17
|
+
|
|
1
18
|
2023.09.13, v4.2.0
|
|
2
19
|
|
|
3
20
|
feature:
|
|
@@ -70,6 +70,7 @@ const isExcludedFromChain = satisfy([
|
|
|
70
70
|
isIfStatement,
|
|
71
71
|
]);
|
|
72
72
|
|
|
73
|
+
module.exports.likeChain = likeChain;
|
|
73
74
|
function likeChain(path) {
|
|
74
75
|
const [root, properties] = chain(path);
|
|
75
76
|
|
|
@@ -82,9 +83,8 @@ function likeChain(path) {
|
|
|
82
83
|
if (calls.length === 2 && !firstCall.name)
|
|
83
84
|
return false;
|
|
84
85
|
|
|
85
|
-
if (isArgOfCall(path))
|
|
86
|
+
if (isArgOfCall(path))
|
|
86
87
|
return false;
|
|
87
|
-
}
|
|
88
88
|
|
|
89
89
|
return calls.length > 1;
|
|
90
90
|
}
|
|
@@ -12,12 +12,25 @@ const {
|
|
|
12
12
|
} = require('../../is');
|
|
13
13
|
|
|
14
14
|
const {parseComments} = require('../../comment/comment');
|
|
15
|
+
const {likeChain} = require('../member-expression/member-expressions');
|
|
15
16
|
|
|
16
17
|
const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
17
18
|
const isLogical = (path) => path.get('argument').isLogicalExpression();
|
|
18
19
|
const isValue = (path) => path.get('properties.0.value').node;
|
|
19
20
|
const isParentExpression = (path) => path.parentPath.isExpressionStatement();
|
|
20
21
|
|
|
22
|
+
const isMemberExpressionCallee = ({parentPath}) => {
|
|
23
|
+
if (!parentPath.isCallExpression())
|
|
24
|
+
return false;
|
|
25
|
+
|
|
26
|
+
const callee = parentPath.get('callee');
|
|
27
|
+
|
|
28
|
+
if (!callee.isMemberExpression())
|
|
29
|
+
return false;
|
|
30
|
+
|
|
31
|
+
return likeChain(callee);
|
|
32
|
+
};
|
|
33
|
+
|
|
21
34
|
module.exports.ObjectExpression = (path, {print, maybe, indent, write}, semantics) => {
|
|
22
35
|
const {trailingComma} = semantics;
|
|
23
36
|
indent.inc();
|
|
@@ -34,6 +47,8 @@ module.exports.ObjectExpression = (path, {print, maybe, indent, write}, semantic
|
|
|
34
47
|
|
|
35
48
|
const n = properties.length - 1;
|
|
36
49
|
|
|
50
|
+
maybe.indent.inc(isMemberExpressionCallee(path));
|
|
51
|
+
|
|
37
52
|
for (const [index, property] of properties.entries()) {
|
|
38
53
|
if (property.isSpreadElement()) {
|
|
39
54
|
const logical = isLogical(property);
|
|
@@ -68,6 +83,8 @@ module.exports.ObjectExpression = (path, {print, maybe, indent, write}, semantic
|
|
|
68
83
|
maybe.indent(manyLines);
|
|
69
84
|
print('}');
|
|
70
85
|
maybe.print(parens, ')');
|
|
86
|
+
|
|
87
|
+
maybe.indent.dec(isMemberExpressionCallee(path));
|
|
71
88
|
};
|
|
72
89
|
|
|
73
90
|
const hasNextLeadingComment = (path) => {
|
|
@@ -1,33 +1,47 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
4
|
+
const {isTSConditionalType} = types;
|
|
5
|
+
|
|
6
|
+
module.exports.TSMappedType = (path, {print, indent, maybe}) => {
|
|
7
|
+
const {
|
|
8
|
+
readonly,
|
|
9
|
+
optional,
|
|
10
|
+
nameType,
|
|
11
|
+
} = path.node;
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
|
|
13
|
+
print('{');
|
|
14
|
+
print.newline();
|
|
8
15
|
indent.inc();
|
|
9
16
|
indent();
|
|
10
17
|
|
|
11
18
|
if (readonly) {
|
|
12
|
-
maybe.
|
|
13
|
-
|
|
19
|
+
maybe.print(readonly === '-', '-');
|
|
20
|
+
print('readonly ');
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
print('[');
|
|
17
24
|
print('__typeParameter');
|
|
18
|
-
|
|
25
|
+
|
|
26
|
+
if (nameType) {
|
|
27
|
+
print(' as');
|
|
28
|
+
maybe.space(!isTSConditionalType(nameType));
|
|
29
|
+
print('__nameType');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
print(']');
|
|
19
33
|
|
|
20
34
|
if (optional) {
|
|
21
|
-
maybe.
|
|
22
|
-
maybe.
|
|
23
|
-
|
|
35
|
+
maybe.print(optional === '+', '+');
|
|
36
|
+
maybe.print(optional === '-', '-');
|
|
37
|
+
print('?');
|
|
24
38
|
}
|
|
25
39
|
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
print(':');
|
|
41
|
+
print.space();
|
|
28
42
|
print('__typeAnnotation');
|
|
29
|
-
|
|
43
|
+
print(';');
|
|
30
44
|
indent.dec();
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
print.breakline();
|
|
46
|
+
print('}');
|
|
33
47
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.1.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",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@putout/babel": "^1.1.1",
|
|
30
|
-
"@putout/compare": "^
|
|
31
|
-
"@putout/operate": "^
|
|
30
|
+
"@putout/compare": "^13.0.0",
|
|
31
|
+
"@putout/operate": "^11.0.0",
|
|
32
32
|
"@putout/processor-json": "^7.0.0",
|
|
33
33
|
"fullstore": "^3.0.0",
|
|
34
34
|
"just-snake-case": "^3.2.0",
|
|
@@ -48,22 +48,22 @@
|
|
|
48
48
|
"@babel/plugin-codemod-object-assign-to-object-spread": "^7.10.4",
|
|
49
49
|
"@putout/plugin-minify": "^4.0.0",
|
|
50
50
|
"@putout/plugin-printer": "^2.0.0",
|
|
51
|
-
"@putout/plugin-promises": "^
|
|
52
|
-
"@putout/plugin-react-hook-form": "^
|
|
51
|
+
"@putout/plugin-promises": "^13.0.0",
|
|
52
|
+
"@putout/plugin-react-hook-form": "^4.0.0",
|
|
53
53
|
"@putout/plugin-react-hooks": "^5.0.0",
|
|
54
54
|
"acorn": "^8.8.2",
|
|
55
55
|
"c8": "^8.0.0",
|
|
56
56
|
"escover": "^3.0.0",
|
|
57
57
|
"eslint": "^8.0.1",
|
|
58
58
|
"eslint-plugin-n": "^16.0.0",
|
|
59
|
-
"eslint-plugin-putout": "^
|
|
60
|
-
"estree-to-babel": "^
|
|
59
|
+
"eslint-plugin-putout": "^20.0.0",
|
|
60
|
+
"estree-to-babel": "^7.0.0",
|
|
61
61
|
"just-kebab-case": "^4.2.0",
|
|
62
62
|
"madrun": "^9.0.0",
|
|
63
63
|
"mock-require": "^3.0.3",
|
|
64
64
|
"montag": "^1.0.0",
|
|
65
65
|
"nodemon": "^3.0.1",
|
|
66
|
-
"putout": "^
|
|
66
|
+
"putout": "^32.0.4",
|
|
67
67
|
"supertape": "^8.0.0",
|
|
68
68
|
"try-catch": "^3.0.0"
|
|
69
69
|
},
|