@putout/printer 5.5.0 → 5.5.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
CHANGED
|
@@ -13,10 +13,11 @@ const {
|
|
|
13
13
|
|
|
14
14
|
const {parseComments} = require('../../comment/comment');
|
|
15
15
|
const {likeChain} = require('../member-expression/member-expressions');
|
|
16
|
-
const {maybeParens} = require('../function/parens');
|
|
17
16
|
|
|
17
|
+
const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
18
18
|
const isLogical = (path) => path.get('argument').isLogicalExpression();
|
|
19
19
|
const isValue = (path) => path.get('properties.0.value').node;
|
|
20
|
+
const isParentExpression = (path) => path.parentPath.isExpressionStatement();
|
|
20
21
|
|
|
21
22
|
const isMemberExpressionCallee = ({parentPath}) => {
|
|
22
23
|
if (!parentPath.isCallExpression())
|
|
@@ -30,16 +31,16 @@ const isMemberExpressionCallee = ({parentPath}) => {
|
|
|
30
31
|
return likeChain(callee);
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
module.exports.ObjectExpression =
|
|
34
|
+
module.exports.ObjectExpression = (path, {print, maybe, indent, write}, semantics) => {
|
|
34
35
|
const {trailingComma} = semantics;
|
|
35
36
|
indent.inc();
|
|
36
37
|
|
|
37
38
|
const properties = path.get('properties');
|
|
38
39
|
const {length} = properties;
|
|
40
|
+
const parens = isParens(path);
|
|
39
41
|
const manyLines = !isOneLine(path);
|
|
40
42
|
|
|
41
|
-
maybe.print(
|
|
42
|
-
|
|
43
|
+
maybe.print(parens, '(');
|
|
43
44
|
print('{');
|
|
44
45
|
parseComments(path, {write}, semantics);
|
|
45
46
|
maybe.print.newline(manyLines);
|
|
@@ -81,9 +82,10 @@ module.exports.ObjectExpression = maybeParens((path, {print, maybe, indent, writ
|
|
|
81
82
|
indent.dec();
|
|
82
83
|
maybe.indent(manyLines);
|
|
83
84
|
print('}');
|
|
85
|
+
maybe.print(parens, ')');
|
|
84
86
|
|
|
85
87
|
maybe.indent.dec(isMemberExpressionCallee(path));
|
|
86
|
-
}
|
|
88
|
+
};
|
|
87
89
|
|
|
88
90
|
const hasNextLeadingComment = (path) => {
|
|
89
91
|
const next = path.getNextSibling();
|
|
@@ -132,3 +134,10 @@ function isOneLine(path) {
|
|
|
132
134
|
|
|
133
135
|
return !isValue(path);
|
|
134
136
|
}
|
|
137
|
+
|
|
138
|
+
function isParens(path) {
|
|
139
|
+
if (isBodyOfArrow(path))
|
|
140
|
+
return true;
|
|
141
|
+
|
|
142
|
+
return isParentExpression(path);
|
|
143
|
+
}
|
|
@@ -2,4 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const {ObjectExpression} = require('./object-expression');
|
|
4
4
|
|
|
5
|
-
module.exports.RecordExpression =
|
|
5
|
+
module.exports.RecordExpression = (path, operations, semantics) => {
|
|
6
|
+
const {write} = operations;
|
|
7
|
+
write('#');
|
|
8
|
+
ObjectExpression(path, operations, semantics);
|
|
9
|
+
};
|
package/package.json
CHANGED