@putout/printer 5.5.1 → 5.7.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 +10 -0
- package/README.md +1 -1
- package/lib/tokenize/expressions/class/class-property.js +19 -0
- package/lib/tokenize/expressions/class/class.js +2 -2
- package/lib/tokenize/expressions/function/class-method.js +8 -0
- package/lib/tokenize/expressions/index.js +2 -0
- package/lib/tokenize/statements/for-of-statement/for-of-statement.js +1 -1
- package/package.json +1 -1
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
|
|
|
@@ -5,6 +5,7 @@ const {maybePrintTypeAnnotation} = require('../../literals/maybe-type-annotation
|
|
|
5
5
|
|
|
6
6
|
module.exports.ClassProperty = ClassProperty;
|
|
7
7
|
module.exports.ClassPrivateProperty = ClassProperty;
|
|
8
|
+
|
|
8
9
|
module.exports.PrivateName = (path, {print}) => {
|
|
9
10
|
print('#');
|
|
10
11
|
print('__id');
|
|
@@ -15,10 +16,23 @@ function ClassProperty(path, printer) {
|
|
|
15
16
|
const {node} = path;
|
|
16
17
|
const {
|
|
17
18
|
accessibility,
|
|
19
|
+
accessor,
|
|
18
20
|
declare,
|
|
19
21
|
optional,
|
|
22
|
+
decorators,
|
|
20
23
|
} = node;
|
|
21
24
|
|
|
25
|
+
if (decorators) {
|
|
26
|
+
for (const decorator of path.get('decorators')) {
|
|
27
|
+
print(decorator);
|
|
28
|
+
print.breakline();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (accessor) {
|
|
33
|
+
print('accessor ');
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
const value = path.get('value');
|
|
23
37
|
|
|
24
38
|
maybe.print(accessibility, `${accessibility} `);
|
|
@@ -40,3 +54,8 @@ function ClassProperty(path, printer) {
|
|
|
40
54
|
print(';');
|
|
41
55
|
print.newline();
|
|
42
56
|
}
|
|
57
|
+
|
|
58
|
+
module.exports.ClassAccessorProperty = (path, printer) => {
|
|
59
|
+
path.node.accessor = true;
|
|
60
|
+
ClassProperty(path, printer);
|
|
61
|
+
};
|
|
@@ -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,12 +13,20 @@ const ClassMethod = {
|
|
|
13
13
|
generator,
|
|
14
14
|
accessibility,
|
|
15
15
|
returnType,
|
|
16
|
+
decorators,
|
|
16
17
|
} = node;
|
|
17
18
|
|
|
18
19
|
const isConstructor = kind === 'constructor';
|
|
19
20
|
const isMethod = kind === 'method';
|
|
20
21
|
const isGetter = /get|set/.test(kind);
|
|
21
22
|
|
|
23
|
+
if (decorators) {
|
|
24
|
+
for (const decorator of path.get('decorators')) {
|
|
25
|
+
print(decorator);
|
|
26
|
+
print.breakline();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
if (accessibility) {
|
|
23
31
|
print(accessibility);
|
|
24
32
|
print(' ');
|
|
@@ -22,6 +22,7 @@ const {ObjectPattern} = require('./object-pattern/object-pattern');
|
|
|
22
22
|
|
|
23
23
|
const {
|
|
24
24
|
ClassProperty,
|
|
25
|
+
ClassAccessorProperty,
|
|
25
26
|
ClassPrivateProperty,
|
|
26
27
|
PrivateName,
|
|
27
28
|
} = require('./class/class-property');
|
|
@@ -57,6 +58,7 @@ module.exports = {
|
|
|
57
58
|
CallExpression,
|
|
58
59
|
ClassExpression,
|
|
59
60
|
ClassProperty,
|
|
61
|
+
ClassAccessorProperty,
|
|
60
62
|
ClassPrivateProperty,
|
|
61
63
|
ClassDeclaration,
|
|
62
64
|
ConditionalExpression,
|
package/package.json
CHANGED