@putout/printer 11.12.0 → 11.14.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
|
+
2025.01.05, v11.14.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- ad933f7 @putout/printer: MemberExpression: chain: path.get
|
|
5
|
+
|
|
6
|
+
2024.12.31, v11.13.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 99c7207 @putout/printer: TSUnionType: always add parens when inside TSArrayType (benjamn/recast#1416)
|
|
10
|
+
|
|
1
11
|
2024.12.25, v11.12.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -10,8 +10,8 @@ const {maybeParens} = require('../../maybe/maybe-parens');
|
|
|
10
10
|
|
|
11
11
|
const {
|
|
12
12
|
isUnaryExpression,
|
|
13
|
-
isArrowFunctionExpression,
|
|
14
13
|
isIfStatement,
|
|
14
|
+
isCallExpression,
|
|
15
15
|
} = types;
|
|
16
16
|
|
|
17
17
|
const isArgOfCall = (path) => path.parentPath.isCallExpression() && path.parentPath.get('arguments.0') === path;
|
|
@@ -68,11 +68,13 @@ module.exports.OptionalMemberExpression = maybeParens((path, {print, maybe}) =>
|
|
|
68
68
|
|
|
69
69
|
const isCall = (a) => a.type === 'CallExpression';
|
|
70
70
|
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
const isPathGet = (property) => {
|
|
72
|
+
return isCallExpression(property, {
|
|
73
|
+
name: 'get',
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const isExcludedFromChain = satisfy([isUnaryExpression, isIfStatement]);
|
|
76
78
|
|
|
77
79
|
const isIfUp = (path) => {
|
|
78
80
|
const ifPath = path.find(isIfStatement);
|
|
@@ -102,6 +104,9 @@ function likeChain(path) {
|
|
|
102
104
|
if (isExcludedFromChain(root))
|
|
103
105
|
return false;
|
|
104
106
|
|
|
107
|
+
if (properties.find(isPathGet))
|
|
108
|
+
return false;
|
|
109
|
+
|
|
105
110
|
if (path.find(isIfUp))
|
|
106
111
|
return false;
|
|
107
112
|
|
|
@@ -4,10 +4,12 @@ const {types} = require('@putout/babel');
|
|
|
4
4
|
|
|
5
5
|
const {markAfter} = require('../../mark');
|
|
6
6
|
const {exists, isNext} = require('../../is');
|
|
7
|
+
|
|
7
8
|
const {
|
|
8
9
|
isBlockStatement,
|
|
9
10
|
isFunctionDeclaration,
|
|
10
11
|
} = types;
|
|
12
|
+
|
|
11
13
|
const isInside = ({parentPath}) => !parentPath.parentPath.isProgram();
|
|
12
14
|
const isEmptyConsequent = (path) => path.get('consequent').isEmptyStatement();
|
|
13
15
|
|
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
const {maybeParens} = require('../../maybe/maybe-parens');
|
|
4
4
|
const insideTypeDeclaration = ({parentPath}) => parentPath.isTSTypeAliasDeclaration();
|
|
5
5
|
|
|
6
|
-
module.exports.TSUnionType = maybeParens(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
module.exports.TSUnionType = maybeParens({
|
|
7
|
+
condition: (path) => {
|
|
8
|
+
return path.parentPath.isTSArrayType();
|
|
9
|
+
},
|
|
10
|
+
print: (path, printer, {maxTypesInOneLine}) => {
|
|
11
|
+
const types = path.get('types');
|
|
12
|
+
const {length} = types;
|
|
13
|
+
|
|
14
|
+
if (!insideTypeDeclaration(path) || length <= maxTypesInOneLine)
|
|
15
|
+
printInOneLine(types, printer);
|
|
16
|
+
else
|
|
17
|
+
printInCoupleLines(types, printer);
|
|
18
|
+
},
|
|
14
19
|
});
|
|
15
20
|
|
|
16
21
|
function printInOneLine(types, {traverse, write}) {
|
package/package.json
CHANGED