@putout/printer 15.26.0 → 15.26.2
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.11.07, v15.26.2
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- c388dfa @putout/printer: IfStatement: consiquent is TryCatchStatement: add newline before else
|
|
5
|
+
|
|
6
|
+
2025.10.31, v15.26.1
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- c929351 @putout/printer: ObjectPattern: calculateLongAssignPattern: simplify
|
|
10
|
+
|
|
1
11
|
2025.10.31, v15.26.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -23,15 +23,17 @@ module.exports.calculateAssigns = (property, semantics) => {
|
|
|
23
23
|
module.exports.isLongAssignPattern = isLongAssignPattern;
|
|
24
24
|
|
|
25
25
|
function isLongAssignPattern(path, semantics) {
|
|
26
|
-
|
|
26
|
+
const {key, value} = path.node;
|
|
27
|
+
|
|
28
|
+
if (!isAssignmentPattern(value))
|
|
27
29
|
return false;
|
|
28
30
|
|
|
29
|
-
if (!isIdentifier(
|
|
31
|
+
if (!isIdentifier(key))
|
|
30
32
|
return true;
|
|
31
33
|
|
|
32
34
|
const {maxPropertiesLengthInOneLine} = semantics;
|
|
33
35
|
|
|
34
|
-
return
|
|
36
|
+
return key.name.length > maxPropertiesLengthInOneLine;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
function isComplexObject(node) {
|
|
@@ -13,8 +13,24 @@ const {
|
|
|
13
13
|
isBlockStatement,
|
|
14
14
|
isFunctionDeclaration,
|
|
15
15
|
isStatement,
|
|
16
|
+
isExpressionStatement,
|
|
17
|
+
isReturnStatement,
|
|
18
|
+
isContinueStatement,
|
|
16
19
|
} = types;
|
|
17
20
|
|
|
21
|
+
const isStatementNotExpression = (path) => {
|
|
22
|
+
if (isBlockStatement(path))
|
|
23
|
+
return false;
|
|
24
|
+
|
|
25
|
+
if (isReturnStatement(path))
|
|
26
|
+
return false;
|
|
27
|
+
|
|
28
|
+
if (isContinueStatement(path))
|
|
29
|
+
return false;
|
|
30
|
+
|
|
31
|
+
return !isExpressionStatement(path);
|
|
32
|
+
};
|
|
33
|
+
|
|
18
34
|
const isTopLevel = ({parentPath}) => parentPath.parentPath.isProgram();
|
|
19
35
|
const isEmptyConsequent = (path) => path.get('consequent').isEmptyStatement();
|
|
20
36
|
|
|
@@ -83,15 +99,17 @@ module.exports.IfStatement = {
|
|
|
83
99
|
write.space();
|
|
84
100
|
traverse(alternate);
|
|
85
101
|
} else if (alternate.isIfStatement()) {
|
|
86
|
-
if (alternate.get('consequent').isBlockStatement())
|
|
102
|
+
if (alternate.get('consequent').isBlockStatement()) {
|
|
87
103
|
write.space();
|
|
88
|
-
else
|
|
104
|
+
} else {
|
|
105
|
+
maybe.write.newline(isStatementNotExpression(consequent));
|
|
89
106
|
indent();
|
|
107
|
+
}
|
|
90
108
|
|
|
91
109
|
write('else ');
|
|
92
110
|
traverse(alternate);
|
|
93
111
|
} else if (exists(alternate)) {
|
|
94
|
-
maybe.write.newline(isVar);
|
|
112
|
+
maybe.write.newline(isVar || isStatementNotExpression(consequent));
|
|
95
113
|
maybe.indent(!isConsequentBlock);
|
|
96
114
|
maybe.write.space(isConsequentBlock);
|
|
97
115
|
write('else');
|
package/package.json
CHANGED