@putout/printer 18.47.3 → 18.47.5
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,15 @@
|
|
|
1
|
+
2026.10.04, v18.47.5
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 6c71fe95 @putout/printer: CallExpression: comment: interanl
|
|
5
|
+
- f4265854 @putout/printer: CallExpression: filled array
|
|
6
|
+
|
|
7
|
+
2026.10.03, v18.47.4
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- 4b751ba4 @putout/printer: CallExpression: isCommaAfterArg: merge
|
|
11
|
+
- df951f4f @putout/printer: CallExpression: isBreaklineAfterAllArgs
|
|
12
|
+
|
|
1
13
|
2026.10.03, v18.47.3
|
|
2
14
|
|
|
3
15
|
feature:
|
|
@@ -3,6 +3,15 @@ import {isInsideCall} from '#is';
|
|
|
3
3
|
import {maybeParens} from '#maybe-parens';
|
|
4
4
|
import {createTypeChecker} from '#type-checker';
|
|
5
5
|
|
|
6
|
+
const isLast = (arg) => {
|
|
7
|
+
const {length} = arg.parentPath.node.arguments;
|
|
8
|
+
const n = length - 1;
|
|
9
|
+
|
|
10
|
+
return arg.__putout_printer_index === n;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const getFirstArg = (fn) => (path) => fn(path.get('arguments.0'));
|
|
14
|
+
|
|
6
15
|
const getMaxArgsInOneLine = (path, {maxArgsInOneLine}) => maxArgsInOneLine;
|
|
7
16
|
const firstArgIsArray = (path) => isArrayExpression(path.node?.arguments?.[0]);
|
|
8
17
|
|
|
@@ -57,13 +66,18 @@ export const CallExpression = maybeParens((path, printer, semantics) => {
|
|
|
57
66
|
|
|
58
67
|
export const OptionalCallExpression = CallExpression;
|
|
59
68
|
|
|
60
|
-
const
|
|
69
|
+
const isSpaceBeforeArg = createTypeChecker([
|
|
61
70
|
['-: parentPath -> !', isMaxArgs],
|
|
62
71
|
['+: -> ArrayExpression'],
|
|
63
72
|
]);
|
|
64
73
|
|
|
65
|
-
const
|
|
66
|
-
|
|
74
|
+
const isFilledArray = createTypeChecker([
|
|
75
|
+
'-: -> !ArrayExpression',
|
|
76
|
+
'+: node.elements.length -> +',
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
const isBreaklineBeforeArg = createTypeChecker([
|
|
80
|
+
['-', isFilledArray],
|
|
67
81
|
['+: parentPath', isMaxArgs],
|
|
68
82
|
['+', isMemberCallee],
|
|
69
83
|
['-: parentPath -> !', isMultiline],
|
|
@@ -71,51 +85,58 @@ const isBreaklineAfterArg = createTypeChecker([
|
|
|
71
85
|
]);
|
|
72
86
|
|
|
73
87
|
const isCommaAfterArg = createTypeChecker([
|
|
88
|
+
['+: -> !', isLast],
|
|
89
|
+
['+', isMemberCallee],
|
|
90
|
+
['+: parentPath', isMaxArgs],
|
|
91
|
+
['-: parentPath.node.arguments.length', '<=', 1],
|
|
92
|
+
['+: parentPath', isMultiline],
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
const isBreaklineAfterAllArgs = createTypeChecker([
|
|
74
96
|
['+', isMaxArgs],
|
|
75
|
-
['-:
|
|
76
|
-
['
|
|
97
|
+
['-: -> !', isMultiline],
|
|
98
|
+
['+: node.arguments.length', '>', 1],
|
|
99
|
+
['+', getFirstArg(isMemberCallee)],
|
|
77
100
|
]);
|
|
78
101
|
|
|
102
|
+
const isSpaceAfterArg = createTypeChecker([
|
|
103
|
+
['-: ->', isLast],
|
|
104
|
+
['-: parentPath', isMaxArgs],
|
|
105
|
+
['+: parentPath -> !', isMultiline],
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
const isIndent = createTypeChecker([isMaxArgs, isMultiline]);
|
|
109
|
+
|
|
79
110
|
function printArgs(path, printer, semantics) {
|
|
111
|
+
const {indent, print} = printer;
|
|
80
112
|
const args = parseArgs(path);
|
|
81
|
-
const maxArgs = isMaxArgs(path, semantics);
|
|
82
|
-
const multiline = maxArgs || isMultiline(path, semantics);
|
|
83
|
-
|
|
84
|
-
const {
|
|
85
|
-
indent,
|
|
86
|
-
print,
|
|
87
|
-
maybe,
|
|
88
|
-
} = printer;
|
|
89
113
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
maybe.indent.inc(multiline);
|
|
114
|
+
if (isIndent(path, semantics))
|
|
115
|
+
indent.inc();
|
|
93
116
|
|
|
94
117
|
for (const [i, arg] of args.entries()) {
|
|
95
|
-
|
|
118
|
+
arg.__putout_printer_index = i;
|
|
119
|
+
|
|
120
|
+
if (isSpaceBeforeArg(arg, semantics))
|
|
96
121
|
print.space();
|
|
97
122
|
|
|
98
|
-
if (
|
|
123
|
+
if (isBreaklineBeforeArg(arg, semantics))
|
|
99
124
|
print.breakline();
|
|
100
125
|
|
|
101
126
|
print(arg);
|
|
102
127
|
|
|
103
|
-
if (isCommaAfterArg(
|
|
128
|
+
if (isCommaAfterArg(arg, semantics))
|
|
104
129
|
print(',');
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
130
|
|
|
108
|
-
if (
|
|
109
|
-
print(',');
|
|
110
|
-
|
|
111
|
-
if (i < n)
|
|
131
|
+
if (isSpaceAfterArg(arg, semantics))
|
|
112
132
|
print.space();
|
|
113
133
|
}
|
|
114
134
|
|
|
115
|
-
if (
|
|
135
|
+
if (isIndent(path, semantics))
|
|
116
136
|
indent.dec();
|
|
117
|
-
|
|
118
|
-
|
|
137
|
+
|
|
138
|
+
if (isBreaklineAfterAllArgs(path, semantics))
|
|
139
|
+
print.breakline();
|
|
119
140
|
}
|
|
120
141
|
|
|
121
142
|
function tooLong(path) {
|
|
@@ -128,4 +149,3 @@ function tooLong(path) {
|
|
|
128
149
|
|
|
129
150
|
return false;
|
|
130
151
|
}
|
|
131
|
-
|
package/package.json
CHANGED