@putout/printer 14.5.0 → 14.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
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2025.04.29, v14.6.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 15f94af @putout/printer: FunctionExpression inside 3-elements ArrayExpression tuple
|
|
5
|
+
|
|
6
|
+
2025.04.25, v14.5.1
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- b9d9316 @putout/printer: function: params: printAfterClose -> printBeforeClose
|
|
10
|
+
|
|
1
11
|
2025.04.25, v14.5.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -18,8 +18,8 @@ module.exports.printParams = (path, printer, semantics, customization = {}) => {
|
|
|
18
18
|
braceOpen = '(',
|
|
19
19
|
braceClose = ')',
|
|
20
20
|
printSpace = print.space,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
printAfterOpen = noop,
|
|
22
|
+
printBeforeClose = noop,
|
|
23
23
|
} = customization;
|
|
24
24
|
|
|
25
25
|
if (typeParameters)
|
|
@@ -31,7 +31,7 @@ module.exports.printParams = (path, printer, semantics, customization = {}) => {
|
|
|
31
31
|
}, semantics);
|
|
32
32
|
|
|
33
33
|
parseComments(path, printer, semantics);
|
|
34
|
-
|
|
34
|
+
printAfterOpen();
|
|
35
35
|
|
|
36
36
|
const n = params.length - 1;
|
|
37
37
|
|
|
@@ -49,7 +49,7 @@ module.exports.printParams = (path, printer, semantics, customization = {}) => {
|
|
|
49
49
|
|
|
50
50
|
maybe.print(extra?.trailingComma, ',');
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
printBeforeClose();
|
|
53
53
|
printBraceClose(path, {
|
|
54
54
|
print,
|
|
55
55
|
braceClose,
|
|
@@ -36,14 +36,14 @@ module.exports.printFunctionParams = (path, printer, semantics) => {
|
|
|
36
36
|
printer,
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
const
|
|
39
|
+
const printAfterOpen = createPrintAfterOpen(path, {
|
|
40
40
|
type: 'inc',
|
|
41
41
|
printer,
|
|
42
42
|
isNewline,
|
|
43
43
|
isAllHasComments,
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
const
|
|
46
|
+
const printBeforeClose = createPrintBeforeClose({
|
|
47
47
|
type: 'dec',
|
|
48
48
|
printer,
|
|
49
49
|
isNewline,
|
|
@@ -51,13 +51,13 @@ module.exports.printFunctionParams = (path, printer, semantics) => {
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
printParams(path, printer, semantics, {
|
|
54
|
-
|
|
54
|
+
printAfterOpen,
|
|
55
55
|
printSpace,
|
|
56
|
-
|
|
56
|
+
printBeforeClose,
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
const
|
|
60
|
+
const createPrintAfterOpen = (path, {isNewline, isAllHasComments, printer, type}) => () => {
|
|
61
61
|
if (!isNewline)
|
|
62
62
|
return;
|
|
63
63
|
|
|
@@ -74,7 +74,7 @@ const createPrintBeforeFirst = (path, {isNewline, isAllHasComments, printer, typ
|
|
|
74
74
|
indent();
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
const
|
|
77
|
+
const createPrintBeforeClose = ({isNewline, printer, isAllHasComments, type}) => () => {
|
|
78
78
|
if (!isNewline)
|
|
79
79
|
return;
|
|
80
80
|
|
|
@@ -22,11 +22,22 @@ const {
|
|
|
22
22
|
isExportDeclaration,
|
|
23
23
|
isDoWhileStatement,
|
|
24
24
|
isBlockStatement,
|
|
25
|
+
isArrayExpression,
|
|
25
26
|
} = types;
|
|
26
27
|
|
|
27
28
|
const isFirstStatement = (path) => path.node.body[0];
|
|
28
29
|
const isFirstDirective = (path) => path.node.directives?.[0];
|
|
29
30
|
const isMethodOrArrow = (path) => isArrowFunctionExpression(path) || isObjectMethod(path);
|
|
31
|
+
const isInsideArrayTupleOfThree = (path) => {
|
|
32
|
+
const {parentPath} = path.parentPath;
|
|
33
|
+
|
|
34
|
+
if (!isArrayExpression(parentPath))
|
|
35
|
+
return false;
|
|
36
|
+
|
|
37
|
+
const {length} = parentPath.node.elements;
|
|
38
|
+
|
|
39
|
+
return length === 3;
|
|
40
|
+
};
|
|
30
41
|
|
|
31
42
|
const parentIfWithoutElse = ({parentPath}) => {
|
|
32
43
|
if (!parentPath.isIfStatement())
|
|
@@ -50,7 +61,8 @@ module.exports.BlockStatement = {
|
|
|
50
61
|
if (path.parentPath.isBlockStatement())
|
|
51
62
|
indent();
|
|
52
63
|
|
|
53
|
-
|
|
64
|
+
const insideArray = isInsideArrayTupleOfThree(path);
|
|
65
|
+
maybe.indent.inc(!insideArray);
|
|
54
66
|
write('{');
|
|
55
67
|
|
|
56
68
|
if (isFirstStatement(path) || isFirstDirective(path))
|
|
@@ -71,8 +83,11 @@ module.exports.BlockStatement = {
|
|
|
71
83
|
|
|
72
84
|
parseComments(path, printer, semantics);
|
|
73
85
|
|
|
74
|
-
indent.dec();
|
|
86
|
+
maybe.indent.dec(!insideArray);
|
|
87
|
+
|
|
88
|
+
maybe.indent.dec(insideArray);
|
|
75
89
|
maybe.indent(body.length);
|
|
90
|
+
maybe.indent.inc(insideArray);
|
|
76
91
|
write('}');
|
|
77
92
|
|
|
78
93
|
maybe.indent.dec(callInsideChain);
|
|
@@ -177,3 +192,4 @@ function isTry({parentPath}) {
|
|
|
177
192
|
|
|
178
193
|
return parentPath.parentPath?.isTryStatement();
|
|
179
194
|
}
|
|
195
|
+
|
package/package.json
CHANGED