@putout/printer 5.7.1 → 5.8.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,16 @@
|
|
|
1
|
+
2023.09.23, v5.8.0
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- fe8b718 @putout/printer: ClassProperty: options
|
|
5
|
+
|
|
6
|
+
feature:
|
|
7
|
+
- 0fdc0d5 @putout/printer: maybePrintDecorators
|
|
8
|
+
|
|
9
|
+
2023.09.22, v5.7.2
|
|
10
|
+
|
|
11
|
+
fix:
|
|
12
|
+
- 45631de @putout/printer: avoid leaking mutation of a tree
|
|
13
|
+
|
|
1
14
|
2023.09.22, v5.7.1
|
|
2
15
|
|
|
3
16
|
feature:
|
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {exists
|
|
3
|
+
const {exists} = require('../../is');
|
|
4
4
|
const {maybePrintTypeAnnotation} = require('../../literals/maybe-type-annotation');
|
|
5
|
+
const {maybePrintDecorators} = require('./maybe-print-decorators');
|
|
5
6
|
|
|
6
|
-
module.exports.ClassProperty =
|
|
7
|
-
module.exports.ClassPrivateProperty =
|
|
7
|
+
module.exports.ClassProperty = processClassProperty;
|
|
8
|
+
module.exports.ClassPrivateProperty = processClassProperty;
|
|
8
9
|
|
|
9
10
|
module.exports.PrivateName = (path, {print}) => {
|
|
10
11
|
print('#');
|
|
11
12
|
print('__id');
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
module.exports.ClassAccessorProperty = (path, printer, semantics) => {
|
|
16
|
+
processClassProperty(path, printer, semantics, {
|
|
17
|
+
accessor: true,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function processClassProperty(path, printer, semantics, {accessor} = {}) {
|
|
15
22
|
const {print, maybe} = printer;
|
|
16
23
|
const {node} = path;
|
|
17
24
|
const {
|
|
18
25
|
accessibility,
|
|
19
|
-
accessor,
|
|
20
26
|
declare,
|
|
21
27
|
optional,
|
|
22
|
-
decorators,
|
|
23
28
|
} = node;
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
maybe.print.breakline(isPrev(path));
|
|
28
|
-
print(decorator);
|
|
29
|
-
print.breakline();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (accessor) {
|
|
34
|
-
print('accessor ');
|
|
35
|
-
}
|
|
30
|
+
maybePrintDecorators(path, printer);
|
|
31
|
+
maybe.print(accessor, 'accessor ');
|
|
36
32
|
|
|
37
33
|
const value = path.get('value');
|
|
38
34
|
|
|
@@ -55,8 +51,3 @@ function ClassProperty(path, printer) {
|
|
|
55
51
|
print(';');
|
|
56
52
|
print.newline();
|
|
57
53
|
}
|
|
58
|
-
|
|
59
|
-
module.exports.ClassAccessorProperty = (path, printer) => {
|
|
60
|
-
path.node.accessor = true;
|
|
61
|
-
ClassProperty(path, printer);
|
|
62
|
-
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {isPrev} = require('../../is');
|
|
4
|
+
|
|
5
|
+
module.exports.maybePrintDecorators = (path, printer) => {
|
|
6
|
+
const {print, maybe} = printer;
|
|
7
|
+
const {decorators} = path.node;
|
|
8
|
+
|
|
9
|
+
if (decorators) {
|
|
10
|
+
for (const decorator of path.get('decorators')) {
|
|
11
|
+
maybe.print.breakline(isPrev(path));
|
|
12
|
+
print(decorator);
|
|
13
|
+
print.breakline();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {isNext
|
|
3
|
+
const {isNext} = require('../../is');
|
|
4
4
|
const {printParams} = require('./params');
|
|
5
|
+
const {maybePrintDecorators} = require('../class/maybe-print-decorators');
|
|
5
6
|
|
|
6
7
|
const ClassMethod = {
|
|
7
8
|
print(path, printer, semantics) {
|
|
@@ -13,20 +14,13 @@ const ClassMethod = {
|
|
|
13
14
|
generator,
|
|
14
15
|
accessibility,
|
|
15
16
|
returnType,
|
|
16
|
-
decorators,
|
|
17
17
|
} = node;
|
|
18
18
|
|
|
19
19
|
const isConstructor = kind === 'constructor';
|
|
20
20
|
const isMethod = kind === 'method';
|
|
21
21
|
const isGetter = /get|set/.test(kind);
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
for (const decorator of path.get('decorators')) {
|
|
25
|
-
maybe.print.breakline(isPrev(path));
|
|
26
|
-
print(decorator);
|
|
27
|
-
print.breakline();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
23
|
+
maybePrintDecorators(path, printer);
|
|
30
24
|
|
|
31
25
|
if (accessibility) {
|
|
32
26
|
print(accessibility);
|
package/package.json
CHANGED