@putout/printer 5.16.0 → 5.18.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/lib/tokenize/expressions/array-pattern.js +1 -1
- package/lib/tokenize/expressions/class/class-property.js +2 -2
- package/lib/tokenize/expressions/class/class.js +18 -11
- package/lib/tokenize/expressions/function/class-method.js +1 -1
- package/lib/tokenize/expressions/object-pattern/object-pattern.js +1 -1
- package/lib/tokenize/expressions/rest-element.js +1 -1
- package/lib/tokenize/literals/identifier.js +1 -1
- package/lib/tokenize/{expressions/class → maybe}/maybe-decorators.js +1 -1
- package/lib/tokenize/statements/variable-declaration/variable-declaration.js +1 -1
- package/lib/tokenize/typescript/function/ts-method-signature.js +0 -1
- package/lib/tokenize/typescript/interface/ts-interface-declaration.js +1 -2
- package/lib/tokenize/typescript/namespace/ts-module-declaration.js +1 -1
- package/lib/tokenize/typescript/ts-property-signature.js +1 -1
- package/lib/tokenize/typescript/type/ts-type-alias-declaration.js +1 -1
- package/package.json +1 -1
- /package/lib/tokenize/{typescript/namespace/maybeDeclare.js → maybe/maybe-declare.js} +0 -0
- /package/lib/tokenize/{literals → maybe}/maybe-type-annotation.js +0 -0
package/ChangeLog
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {maybeTypeAnnotation} = require('../
|
|
3
|
+
const {maybeTypeAnnotation} = require('../maybe/maybe-type-annotation');
|
|
4
4
|
const isForOf = ({parentPath}) => parentPath.parentPath.parentPath?.isForOfStatement();
|
|
5
5
|
|
|
6
6
|
module.exports.ArrayPattern = maybeTypeAnnotation((path, {indent, maybe, print}, options) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {exists} = require('../../is');
|
|
4
|
-
const {maybePrintTypeAnnotation} = require('../../
|
|
5
|
-
const {maybeDecorators} = require('
|
|
4
|
+
const {maybePrintTypeAnnotation} = require('../../maybe/maybe-type-annotation');
|
|
5
|
+
const {maybeDecorators} = require('../../maybe/maybe-decorators');
|
|
6
6
|
|
|
7
7
|
const processClassProperty = maybeDecorators((path, printer, semantics, {accessor} = {}) => {
|
|
8
8
|
const {print, maybe} = printer;
|
|
@@ -3,22 +3,18 @@
|
|
|
3
3
|
const {isNext} = require('../../is');
|
|
4
4
|
const {markAfter} = require('../../mark');
|
|
5
5
|
const {maybeDecorators} = require('../../maybe-get');
|
|
6
|
-
const {maybeDeclare} = require('../../
|
|
6
|
+
const {maybeDeclare} = require('../../maybe/maybe-declare');
|
|
7
|
+
const {parseComments} = require('../../comment/comment');
|
|
7
8
|
|
|
8
9
|
const isInsideExport = ({parentPath}) => parentPath.isExportDeclaration();
|
|
9
10
|
|
|
10
11
|
module.exports.ClassExpression = classVisitor;
|
|
11
12
|
|
|
12
13
|
module.exports.ClassDeclaration = {
|
|
13
|
-
print: maybeDeclare((path,
|
|
14
|
+
print: maybeDeclare((path, printer, semantics) => {
|
|
15
|
+
const {indent} = printer;
|
|
14
16
|
indent();
|
|
15
|
-
|
|
16
|
-
classVisitor(path, {
|
|
17
|
-
print,
|
|
18
|
-
indent,
|
|
19
|
-
maybe,
|
|
20
|
-
traverse,
|
|
21
|
-
});
|
|
17
|
+
classVisitor(path, printer, semantics);
|
|
22
18
|
}),
|
|
23
19
|
afterIf(path) {
|
|
24
20
|
if (!isNext(path))
|
|
@@ -36,8 +32,14 @@ module.exports.ClassDeclaration = {
|
|
|
36
32
|
},
|
|
37
33
|
};
|
|
38
34
|
|
|
39
|
-
function classVisitor(path,
|
|
35
|
+
function classVisitor(path, printer, semantics) {
|
|
40
36
|
const {id, abstract} = path.node;
|
|
37
|
+
const {
|
|
38
|
+
print,
|
|
39
|
+
indent,
|
|
40
|
+
maybe,
|
|
41
|
+
traverse,
|
|
42
|
+
} = printer;
|
|
41
43
|
|
|
42
44
|
for (const decorator of maybeDecorators(path)) {
|
|
43
45
|
traverse(decorator);
|
|
@@ -69,13 +71,18 @@ function classVisitor(path, {print, indent, maybe, traverse}) {
|
|
|
69
71
|
maybe.print.newline(path.node.body.body.length);
|
|
70
72
|
indent.inc();
|
|
71
73
|
|
|
72
|
-
const
|
|
74
|
+
const classBody = path.get('body');
|
|
75
|
+
const body = classBody.get('body');
|
|
73
76
|
|
|
74
77
|
for (const item of body) {
|
|
75
78
|
indent();
|
|
76
79
|
traverse(item);
|
|
77
80
|
}
|
|
78
81
|
|
|
82
|
+
if (!body.length) {
|
|
83
|
+
parseComments(classBody, printer, semantics);
|
|
84
|
+
}
|
|
85
|
+
|
|
79
86
|
indent.dec();
|
|
80
87
|
maybe.indent(body.length);
|
|
81
88
|
print('}');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const {isNext} = require('../../is');
|
|
4
4
|
const {printParams} = require('./params');
|
|
5
|
-
const {maybeDecorators} = require('
|
|
5
|
+
const {maybeDecorators} = require('../../maybe/maybe-decorators');
|
|
6
6
|
|
|
7
7
|
const ClassMethod = {
|
|
8
8
|
print: maybeDecorators((path, printer, semantics) => {
|
|
@@ -15,7 +15,7 @@ const {
|
|
|
15
15
|
} = require('../../is');
|
|
16
16
|
|
|
17
17
|
const {checkMaxPropertiesInOneLine} = require('./max-properties-in-one-line');
|
|
18
|
-
const {maybeTypeAnnotation} = require('../../
|
|
18
|
+
const {maybeTypeAnnotation} = require('../../maybe/maybe-type-annotation');
|
|
19
19
|
|
|
20
20
|
const isTwoLevelsDeep = ({parentPath}) => parentPath.parentPath.parentPath.isObjectProperty();
|
|
21
21
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const {maybeDecorators} = require('../maybe-get');
|
|
4
4
|
const {maybeParens} = require('../expressions/function/parens');
|
|
5
|
-
const {maybeTypeAnnotation} = require('
|
|
5
|
+
const {maybeTypeAnnotation} = require('../maybe/maybe-type-annotation');
|
|
6
6
|
|
|
7
7
|
module.exports.Identifier = maybeParens(maybeTypeAnnotation((path, printer) => {
|
|
8
8
|
const {
|
|
@@ -14,7 +14,7 @@ const {maybeSpaceAfterKeyword} = require('./maybe-space-after-keyword');
|
|
|
14
14
|
|
|
15
15
|
const {isConcatenation} = require('../../expressions/binary-expression/concatanate');
|
|
16
16
|
const {parseLeadingComments} = require('../../comment/comment');
|
|
17
|
-
const {maybeDeclare} = require('../../
|
|
17
|
+
const {maybeDeclare} = require('../../maybe/maybe-declare');
|
|
18
18
|
|
|
19
19
|
const isParentTSModuleBlock = (path) => path.parentPath.isTSModuleBlock();
|
|
20
20
|
const isParentBlock = (path) => /Program|BlockStatement|Export/.test(path.parentPath.type);
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
} = require('@putout/babel').types;
|
|
7
7
|
|
|
8
8
|
const {isNext, isNextParent} = require('../../is');
|
|
9
|
-
const {maybeDeclare} = require('
|
|
9
|
+
const {maybeDeclare} = require('../../maybe/maybe-declare');
|
|
10
10
|
|
|
11
11
|
module.exports.TSInterfaceDeclaration = {
|
|
12
12
|
print: maybeDeclare((path, {print, indent}) => {
|
|
@@ -26,4 +26,3 @@ module.exports.TSInterfaceDeclaration = {
|
|
|
26
26
|
print.breakline();
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {maybeTypeAnnotation} = require('../
|
|
3
|
+
const {maybeTypeAnnotation} = require('../maybe/maybe-type-annotation');
|
|
4
4
|
|
|
5
5
|
module.exports.TSPropertySignature = maybeTypeAnnotation((path, {print, maybe}) => {
|
|
6
6
|
const {optional} = path.node;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const {isLast} = require('../../is');
|
|
4
4
|
const {markAfter} = require('../../mark');
|
|
5
|
-
const {maybeDeclare} = require('
|
|
5
|
+
const {maybeDeclare} = require('../../maybe/maybe-declare');
|
|
6
6
|
const isNextType = (a) => a.getNextSibling().isTSTypeAliasDeclaration();
|
|
7
7
|
|
|
8
8
|
module.exports.TSTypeAliasDeclaration = {
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|