@putout/printer 1.15.0 → 1.15.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
|
+
2023.03.31, v1.15.2
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 7df608f @putout/printer: add ability to indent tryStatement
|
|
5
|
+
|
|
6
|
+
2023.03.31, v1.15.1
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 0fd6fd2 @putout/printer: ArrayExpression: add ability to avoid newline when inside of CallExpression inside of ForOfStatement
|
|
10
|
+
|
|
1
11
|
2023.03.31, v1.15.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -33,12 +33,13 @@ module.exports.ArrayExpression = (path, {print, maybe, indent}) => {
|
|
|
33
33
|
const isNewLine = isNewlineBetweenElements(path, {elements});
|
|
34
34
|
const n = elements.length - 1;
|
|
35
35
|
|
|
36
|
-
maybe.print(isNewLine && elements.length
|
|
36
|
+
maybe.print.newline(isNewLine && elements.length);
|
|
37
37
|
|
|
38
38
|
for (const [index, element] of elements.entries()) {
|
|
39
39
|
maybe.indent(isNewLine);
|
|
40
40
|
print(element);
|
|
41
|
-
maybe.print(isNewLine, '
|
|
41
|
+
maybe.print(isNewLine, ',');
|
|
42
|
+
maybe.print.newline(isNewLine);
|
|
42
43
|
maybe.print(!isNewLine && index < n, ', ');
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -87,6 +88,9 @@ function isIncreaseIndent(path) {
|
|
|
87
88
|
if (!elements.length)
|
|
88
89
|
return false;
|
|
89
90
|
|
|
91
|
+
if (isInsideCallLoop(path))
|
|
92
|
+
return false;
|
|
93
|
+
|
|
90
94
|
if (elements[0].isObjectExpression())
|
|
91
95
|
return true;
|
|
92
96
|
|
|
@@ -111,6 +115,9 @@ function tooLong(path) {
|
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
function isNewlineBetweenElements(path, {elements}) {
|
|
118
|
+
if (isInsideCallLoop(path))
|
|
119
|
+
return false;
|
|
120
|
+
|
|
114
121
|
if (isIncreaseIndent(path))
|
|
115
122
|
return false;
|
|
116
123
|
|
|
@@ -136,3 +143,12 @@ function isTwoStringsDifferentLength([a, b]) {
|
|
|
136
143
|
return round(bLength / aLength) > 2;
|
|
137
144
|
}
|
|
138
145
|
|
|
146
|
+
function isInsideCallLoop(path) {
|
|
147
|
+
if (!path.parentPath.isCallExpression())
|
|
148
|
+
return false;
|
|
149
|
+
|
|
150
|
+
if (!path.parentPath.parentPath.isForOfStatement())
|
|
151
|
+
return false;
|
|
152
|
+
|
|
153
|
+
return true;
|
|
154
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.2",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
|