@putout/printer 18.47.4 → 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
|
@@ -7,7 +7,7 @@ const isLast = (arg) => {
|
|
|
7
7
|
const {length} = arg.parentPath.node.arguments;
|
|
8
8
|
const n = length - 1;
|
|
9
9
|
|
|
10
|
-
return arg.
|
|
10
|
+
return arg.__putout_printer_index === n;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
const getFirstArg = (fn) => (path) => fn(path.get('arguments.0'));
|
|
@@ -66,13 +66,18 @@ export const CallExpression = maybeParens((path, printer, semantics) => {
|
|
|
66
66
|
|
|
67
67
|
export const OptionalCallExpression = CallExpression;
|
|
68
68
|
|
|
69
|
-
const
|
|
69
|
+
const isSpaceBeforeArg = createTypeChecker([
|
|
70
70
|
['-: parentPath -> !', isMaxArgs],
|
|
71
71
|
['+: -> ArrayExpression'],
|
|
72
72
|
]);
|
|
73
73
|
|
|
74
|
-
const
|
|
75
|
-
|
|
74
|
+
const isFilledArray = createTypeChecker([
|
|
75
|
+
'-: -> !ArrayExpression',
|
|
76
|
+
'+: node.elements.length -> +',
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
const isBreaklineBeforeArg = createTypeChecker([
|
|
80
|
+
['-', isFilledArray],
|
|
76
81
|
['+: parentPath', isMaxArgs],
|
|
77
82
|
['+', isMemberCallee],
|
|
78
83
|
['-: parentPath -> !', isMultiline],
|
|
@@ -94,6 +99,12 @@ const isBreaklineAfterAllArgs = createTypeChecker([
|
|
|
94
99
|
['+', getFirstArg(isMemberCallee)],
|
|
95
100
|
]);
|
|
96
101
|
|
|
102
|
+
const isSpaceAfterArg = createTypeChecker([
|
|
103
|
+
['-: ->', isLast],
|
|
104
|
+
['-: parentPath', isMaxArgs],
|
|
105
|
+
['+: parentPath -> !', isMultiline],
|
|
106
|
+
]);
|
|
107
|
+
|
|
97
108
|
const isIndent = createTypeChecker([isMaxArgs, isMultiline]);
|
|
98
109
|
|
|
99
110
|
function printArgs(path, printer, semantics) {
|
|
@@ -103,11 +114,13 @@ function printArgs(path, printer, semantics) {
|
|
|
103
114
|
if (isIndent(path, semantics))
|
|
104
115
|
indent.inc();
|
|
105
116
|
|
|
106
|
-
for (const arg of args) {
|
|
107
|
-
|
|
117
|
+
for (const [i, arg] of args.entries()) {
|
|
118
|
+
arg.__putout_printer_index = i;
|
|
119
|
+
|
|
120
|
+
if (isSpaceBeforeArg(arg, semantics))
|
|
108
121
|
print.space();
|
|
109
122
|
|
|
110
|
-
if (
|
|
123
|
+
if (isBreaklineBeforeArg(arg, semantics))
|
|
111
124
|
print.breakline();
|
|
112
125
|
|
|
113
126
|
print(arg);
|
|
@@ -115,7 +128,7 @@ function printArgs(path, printer, semantics) {
|
|
|
115
128
|
if (isCommaAfterArg(arg, semantics))
|
|
116
129
|
print(',');
|
|
117
130
|
|
|
118
|
-
if (
|
|
131
|
+
if (isSpaceAfterArg(arg, semantics))
|
|
119
132
|
print.space();
|
|
120
133
|
}
|
|
121
134
|
|
|
@@ -126,12 +139,6 @@ function printArgs(path, printer, semantics) {
|
|
|
126
139
|
print.breakline();
|
|
127
140
|
}
|
|
128
141
|
|
|
129
|
-
const isSpace = createTypeChecker([
|
|
130
|
-
['-: parentPath', isMultiline],
|
|
131
|
-
['-: parentPath', isMaxArgs],
|
|
132
|
-
['+: -> !', isLast],
|
|
133
|
-
]);
|
|
134
|
-
|
|
135
142
|
function tooLong(path) {
|
|
136
143
|
const args = parseArgs(path);
|
|
137
144
|
|
package/package.json
CHANGED