@putout/printer 1.98.2 → 1.99.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
|
@@ -2,26 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
const BinaryExpression = {
|
|
4
4
|
condition(path) {
|
|
5
|
+
const parens = path.node.extra?.parenthesized;
|
|
6
|
+
|
|
7
|
+
if (parens)
|
|
8
|
+
return true;
|
|
9
|
+
|
|
5
10
|
return path.parentPath.isAwaitExpression();
|
|
6
11
|
},
|
|
7
12
|
before(path, {print}) {
|
|
8
13
|
print('(');
|
|
9
14
|
},
|
|
10
|
-
print(path, {write, traverse
|
|
15
|
+
print(path, {write, traverse}) {
|
|
11
16
|
const left = path.get('left');
|
|
12
17
|
const right = path.get('right');
|
|
13
|
-
const isLeft = isLogical(path, left);
|
|
14
|
-
const isRight = isLogical(path, right);
|
|
15
18
|
|
|
16
|
-
maybe.write(isLeft, '(');
|
|
17
19
|
traverse(left);
|
|
18
|
-
maybe.write(isLeft, ')');
|
|
19
20
|
write.space();
|
|
20
21
|
write(path.node.operator);
|
|
21
22
|
write.space();
|
|
22
|
-
maybe.write(isRight, '(');
|
|
23
23
|
traverse(right);
|
|
24
|
-
maybe.write(isRight, ')');
|
|
25
24
|
},
|
|
26
25
|
after(path, {print}) {
|
|
27
26
|
print(')');
|
|
@@ -30,12 +29,3 @@ const BinaryExpression = {
|
|
|
30
29
|
|
|
31
30
|
module.exports.BinaryExpression = BinaryExpression;
|
|
32
31
|
module.exports.LogicalExpression = BinaryExpression;
|
|
33
|
-
|
|
34
|
-
const isLogical = (main, path) => {
|
|
35
|
-
const is = path.isLogicalExpression();
|
|
36
|
-
|
|
37
|
-
if (!is)
|
|
38
|
-
return false;
|
|
39
|
-
|
|
40
|
-
return main.node.operator !== path.node.operator;
|
|
41
|
-
};
|
|
@@ -46,14 +46,10 @@ function unaryExpression(path, {maybe, traverse}) {
|
|
|
46
46
|
} = path.node;
|
|
47
47
|
|
|
48
48
|
const argPath = path.get('argument');
|
|
49
|
-
const round = argPath.isBinaryExpression() || argPath.isLogicalExpression();
|
|
50
49
|
|
|
51
50
|
maybe.print(prefix, operator);
|
|
52
51
|
maybe.print(isWord(operator), ' ');
|
|
53
52
|
|
|
54
|
-
maybe.print(round, '(');
|
|
55
53
|
traverse(argPath);
|
|
56
|
-
maybe.print(round, ')');
|
|
57
|
-
|
|
58
54
|
maybe.print(!prefix, operator);
|
|
59
55
|
}
|
|
@@ -23,7 +23,9 @@ module.exports.ForOfStatement = {
|
|
|
23
23
|
},
|
|
24
24
|
print(path, {indent, print, maybe, traverse}) {
|
|
25
25
|
indent();
|
|
26
|
-
print('for
|
|
26
|
+
print('for');
|
|
27
|
+
print.space();
|
|
28
|
+
print('(');
|
|
27
29
|
print('__left');
|
|
28
30
|
print(' of ');
|
|
29
31
|
print('__right');
|
|
@@ -32,7 +34,7 @@ module.exports.ForOfStatement = {
|
|
|
32
34
|
const bodyPath = path.get('body');
|
|
33
35
|
|
|
34
36
|
if (bodyPath.isBlockStatement()) {
|
|
35
|
-
print(
|
|
37
|
+
print.space();
|
|
36
38
|
print('__body');
|
|
37
39
|
|
|
38
40
|
const {length} = bodyPath.node.body;
|
package/package.json
CHANGED