@putout/printer 5.5.0 → 5.6.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
package/README.md
CHANGED
|
@@ -132,7 +132,7 @@ const overrides = {
|
|
|
132
132
|
- `newline` - symbol for used for line separation;
|
|
133
133
|
- `space` - default symbol used for space character;
|
|
134
134
|
- `splitter` - mandatory symbol that used inside of statements like this:
|
|
135
|
-
- `roundBraceOpen` and `roundBraceClose` symbols to
|
|
135
|
+
- `roundBraceOpen` and `roundBraceClose` symbols to output braces in a single argument arrow function expressions: `(a) => {}`.
|
|
136
136
|
|
|
137
137
|
Default options produce:
|
|
138
138
|
|
|
@@ -36,7 +36,7 @@ module.exports.ClassDeclaration = {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
function classVisitor(path, {print, indent, maybe, traverse}) {
|
|
39
|
-
const {abstract} = path.node;
|
|
39
|
+
const {id, abstract} = path.node;
|
|
40
40
|
|
|
41
41
|
for (const decorator of maybeDecorators(path)) {
|
|
42
42
|
traverse(decorator);
|
|
@@ -58,7 +58,7 @@ function classVisitor(path, {print, indent, maybe, traverse}) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (node.superClass) {
|
|
61
|
-
maybe.print(
|
|
61
|
+
maybe.print(id && !node.implements, ' ');
|
|
62
62
|
print('extends ');
|
|
63
63
|
print('__superClass');
|
|
64
64
|
}
|
|
@@ -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