@putout/printer 2.3.0 → 2.5.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
|
+
2023.06.12, v2.5.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 1810515 @putout/printer: WhileStatement: maybe
|
|
5
|
+
|
|
6
|
+
2023.06.12, v2.4.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 1aa1e9e @putout/printer: ObjectExpression: improve support of using as not last argument of CallExpression
|
|
10
|
+
|
|
1
11
|
2023.06.12, v2.3.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -79,6 +79,17 @@ const hasNextLeadingComment = (path) => {
|
|
|
79
79
|
return hasLeadingComment(next);
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
const notLastArgInsideCall = (path) => {
|
|
83
|
+
const {parentPath} = path;
|
|
84
|
+
|
|
85
|
+
if (!parentPath.isCallExpression())
|
|
86
|
+
return false;
|
|
87
|
+
|
|
88
|
+
return path !== parentPath
|
|
89
|
+
.get('arguments')
|
|
90
|
+
.at(-1);
|
|
91
|
+
};
|
|
92
|
+
|
|
82
93
|
function shouldAddNewline(path) {
|
|
83
94
|
if (!path.parentPath.isLogicalExpression())
|
|
84
95
|
return false;
|
|
@@ -96,6 +107,9 @@ function isOneLine(path) {
|
|
|
96
107
|
if (!length)
|
|
97
108
|
return true;
|
|
98
109
|
|
|
110
|
+
if (notLastArgInsideCall(path))
|
|
111
|
+
return ONE_LINE;
|
|
112
|
+
|
|
99
113
|
if (isForOf(path))
|
|
100
114
|
return ONE_LINE;
|
|
101
115
|
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {isLast} = require('../is');
|
|
4
|
+
const {markAfter} = require('../mark');
|
|
4
5
|
|
|
5
|
-
module.exports.WhileStatement =
|
|
6
|
-
print(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
module.exports.WhileStatement = {
|
|
7
|
+
print(path, {print, indent}) {
|
|
8
|
+
print('while (');
|
|
9
|
+
print('__test');
|
|
10
|
+
print(')');
|
|
11
|
+
|
|
12
|
+
if (path.node.body.body) {
|
|
13
|
+
print(' ');
|
|
14
|
+
print('__body');
|
|
15
|
+
} else {
|
|
16
|
+
indent.inc();
|
|
17
|
+
print.newline();
|
|
18
|
+
print('__body');
|
|
19
|
+
indent.dec();
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
afterIf(path) {
|
|
23
|
+
if (isLast(path))
|
|
24
|
+
return false;
|
|
25
|
+
|
|
26
|
+
return true;
|
|
27
|
+
},
|
|
28
|
+
after(path, {print}) {
|
|
21
29
|
print.linebreak();
|
|
22
|
-
|
|
30
|
+
markAfter(path);
|
|
31
|
+
},
|
|
23
32
|
};
|
|
24
33
|
|
|
25
|
-
function shouldAddNewlineAfter(path) {
|
|
26
|
-
if (isLast(path))
|
|
27
|
-
return false;
|
|
28
|
-
|
|
29
|
-
return true;
|
|
30
|
-
}
|
package/package.json
CHANGED