@putout/printer 2.13.0 → 2.13.1
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 +5 -0
- package/lib/tokenize/expressions/array-expression/array-expression.js +1 -4
- package/lib/tokenize/expressions/array-expression/new-line.js +3 -12
- package/lib/tokenize/expressions/binary-expression/concatanate.js +1 -4
- package/lib/tokenize/expressions/object-expression/object-expression.js +1 -4
- package/lib/tokenize/expressions/object-pattern/object-pattern.js +1 -4
- package/lib/tokenize/statements/block-statement/block-statement.js +2 -8
- package/lib/tokenize/statements/export-declaration/export-default-declaration.js +1 -4
- package/lib/tokenize/statements/expression-statement.js +1 -4
- package/lib/tokenize/statements/for-of-statement.js +1 -6
- package/lib/tokenize/statements/if-statement/if-statement.js +1 -4
- package/lib/tokenize/statements/import-declaration/import-declaration.js +1 -4
- package/lib/tokenize/statements/variable-declaration/variable-declaration.js +1 -4
- package/lib/tokenize/statements/while-statement.js +1 -4
- package/lib/tokenize/typescript/ts-type-alias-declaration.js +1 -4
- package/lib/tokenize/typescript/ts-type-literal.js +1 -4
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -21,10 +21,7 @@ const isTwoLongStrings = ([a, b]) => {
|
|
|
21
21
|
if (!a?.isStringLiteral() || !b?.isStringLiteral())
|
|
22
22
|
return false;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
return true;
|
|
26
|
-
|
|
27
|
-
return false;
|
|
24
|
+
return a.node.value.length > LONG_STRING;
|
|
28
25
|
};
|
|
29
26
|
|
|
30
27
|
module.exports.ArrayExpression = {
|
|
@@ -157,10 +157,7 @@ function isTwoStringsDifferentLength(strings) {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
function isInsideLoop(path) {
|
|
160
|
-
|
|
161
|
-
return false;
|
|
162
|
-
|
|
163
|
-
return true;
|
|
160
|
+
return path.parentPath.isForOfStatement();
|
|
164
161
|
}
|
|
165
162
|
|
|
166
163
|
function tooLong(path) {
|
|
@@ -219,20 +216,14 @@ function isIncreaseIndent(path) {
|
|
|
219
216
|
if (elements[0].isObjectExpression())
|
|
220
217
|
return true;
|
|
221
218
|
|
|
222
|
-
|
|
223
|
-
return true;
|
|
224
|
-
|
|
225
|
-
return false;
|
|
219
|
+
return isStringAndObject(elements);
|
|
226
220
|
}
|
|
227
221
|
|
|
228
222
|
function isInsideCallLoop(path) {
|
|
229
223
|
if (!path.parentPath.isCallExpression())
|
|
230
224
|
return false;
|
|
231
225
|
|
|
232
|
-
|
|
233
|
-
return false;
|
|
234
|
-
|
|
235
|
-
return true;
|
|
226
|
+
return path.parentPath.parentPath.isForOfStatement();
|
|
236
227
|
}
|
|
237
228
|
|
|
238
229
|
const isStringAndObject = (elements) => {
|
|
@@ -128,8 +128,5 @@ function shouldAddNewline(path) {
|
|
|
128
128
|
if (!isForOf(path) && !path.parentPath.isFunction() && n && checkLength(properties))
|
|
129
129
|
return true;
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
return true;
|
|
133
|
-
|
|
134
|
-
return false;
|
|
131
|
+
return parentPath.isObjectProperty();
|
|
135
132
|
}
|
|
@@ -79,10 +79,7 @@ function shouldAddNewlineAfter(path) {
|
|
|
79
79
|
if (isLast(path))
|
|
80
80
|
return false;
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
return false;
|
|
84
|
-
|
|
85
|
-
return true;
|
|
82
|
+
return !isNextIfAlternate(path);
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
function isNextIfAlternate(path) {
|
|
@@ -103,8 +100,5 @@ function isTry({parentPath}) {
|
|
|
103
100
|
if (parentPath.isTryStatement())
|
|
104
101
|
return true;
|
|
105
102
|
|
|
106
|
-
|
|
107
|
-
return true;
|
|
108
|
-
|
|
109
|
-
return false;
|
|
103
|
+
return parentPath.parentPath?.isTryStatement();
|
|
110
104
|
}
|
|
@@ -13,10 +13,7 @@ function shouldAddSemi(path) {
|
|
|
13
13
|
if (path.isClassDeclaration())
|
|
14
14
|
return false;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
return false;
|
|
18
|
-
|
|
19
|
-
return true;
|
|
16
|
+
return !path.isFunctionDeclaration();
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
module.exports.ExportDefaultDeclaration = {
|
|
@@ -57,10 +57,7 @@ module.exports.ExpressionStatement = {
|
|
|
57
57
|
if (hasTrailingComment(path) && isLast(path))
|
|
58
58
|
return true;
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
return true;
|
|
62
|
-
|
|
63
|
-
return false;
|
|
60
|
+
return isBeforeElse(path);
|
|
64
61
|
},
|
|
65
62
|
after(path, {print, maybe, store}) {
|
|
66
63
|
if (hasTrailingComment(path) && isLast(path) && isCoupleLines(path)) {
|
|
@@ -55,12 +55,7 @@ module.exports.ForOfStatement = {
|
|
|
55
55
|
|
|
56
56
|
maybe.markAfter(isMarkedAfter(bodyPath), path);
|
|
57
57
|
},
|
|
58
|
-
afterIf: (path) =>
|
|
59
|
-
if (isNext(path))
|
|
60
|
-
return true;
|
|
61
|
-
|
|
62
|
-
return false;
|
|
63
|
-
},
|
|
58
|
+
afterIf: (path) => isNext(path),
|
|
64
59
|
after(path, {print}) {
|
|
65
60
|
print.linebreak();
|
|
66
61
|
markAfter(path);
|
|
@@ -96,10 +96,7 @@ module.exports.ImportDeclaration = {
|
|
|
96
96
|
if (isLast(path))
|
|
97
97
|
return false;
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
return false;
|
|
101
|
-
|
|
102
|
-
return true;
|
|
99
|
+
return !path.getNextSibling().isImportDeclaration();
|
|
103
100
|
},
|
|
104
101
|
after(path, {print}) {
|
|
105
102
|
print.newline();
|
|
@@ -149,10 +149,7 @@ function shouldAddNewlineBefore(path) {
|
|
|
149
149
|
if (prevPath.isStatement() && !prevPath.isExpressionStatement() && !prevPath.isBlockStatement())
|
|
150
150
|
return false;
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
return true;
|
|
154
|
-
|
|
155
|
-
return false;
|
|
152
|
+
return !isExportDeclaration(path.parentPath) && isCoupleLines(path);
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
function isFirst(path) {
|
|
@@ -33,8 +33,5 @@ module.exports.TSTypeLiteral = (path, {indent, traverse, write, maybe}) => {
|
|
|
33
33
|
function isNewline(path) {
|
|
34
34
|
const members = path.get('members');
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
return true;
|
|
38
|
-
|
|
39
|
-
return false;
|
|
36
|
+
return members.length && members[0].node.typeAnnotation;
|
|
40
37
|
}
|
package/package.json
CHANGED