@putout/printer 18.3.4 → 18.3.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
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
isIf,
|
|
7
7
|
noTrailingComment,
|
|
8
8
|
isNewlineBetweenSiblings,
|
|
9
|
-
noLeadingComment,
|
|
10
9
|
hasLeadingComment,
|
|
11
10
|
exists,
|
|
12
11
|
isInsideCall,
|
|
@@ -32,12 +31,7 @@ const notLastArgInsideCall = (path) => {
|
|
|
32
31
|
const hasNoProperties = (path) => !path.node.properties.length;
|
|
33
32
|
const hasValue = (path) => path.node.properties[0].value;
|
|
34
33
|
|
|
35
|
-
const {
|
|
36
|
-
isMemberExpression,
|
|
37
|
-
isLogicalExpression,
|
|
38
|
-
} = types;
|
|
39
|
-
|
|
40
|
-
const isLogicalArgument = (path) => isLogicalExpression(path.node.argument);
|
|
34
|
+
const {isMemberExpression} = types;
|
|
41
35
|
|
|
42
36
|
const isParens = createTypeChecker([isInsideBody, isInsideExpression]);
|
|
43
37
|
|
|
@@ -72,6 +66,13 @@ export const isManyLines = createTypeChecker([
|
|
|
72
66
|
['+', hasValue],
|
|
73
67
|
]);
|
|
74
68
|
|
|
69
|
+
const isManyLinesOption = (a, {manyLines}) => manyLines;
|
|
70
|
+
|
|
71
|
+
const isIndentBeforeProperty = createTypeChecker([
|
|
72
|
+
['-: -> !', isManyLinesOption],
|
|
73
|
+
['+: -> !', hasLeadingComment],
|
|
74
|
+
]);
|
|
75
|
+
|
|
75
76
|
export const ObjectExpression = (path, printer, semantics) => {
|
|
76
77
|
const {trailingComma} = semantics;
|
|
77
78
|
const {
|
|
@@ -100,39 +101,37 @@ export const ObjectExpression = (path, printer, semantics) => {
|
|
|
100
101
|
maybe.indent.inc(memberCallee);
|
|
101
102
|
|
|
102
103
|
for (const [index, property] of properties.entries()) {
|
|
104
|
+
const couple = length > 1;
|
|
105
|
+
const isLast = index === n;
|
|
106
|
+
|
|
107
|
+
if (isIndentBeforeProperty(property, {manyLines}))
|
|
108
|
+
indent();
|
|
109
|
+
|
|
110
|
+
print(property);
|
|
111
|
+
|
|
112
|
+
if (property.isObjectMethod())
|
|
113
|
+
continue;
|
|
114
|
+
|
|
103
115
|
if (property.isSpreadElement()) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (noLeadingComment(property))
|
|
107
|
-
maybe.indent(length > 1 || logical || manyLines);
|
|
108
|
-
|
|
109
|
-
print(property);
|
|
110
|
-
|
|
111
|
-
if (noTrailingComment(property) && (length > 1 || manyLines)) {
|
|
112
|
-
maybe.print(index !== n || trailingComma, ',');
|
|
116
|
+
if (noTrailingComment(property) && (couple || manyLines)) {
|
|
117
|
+
maybe.print(!isLast || trailingComma, ',');
|
|
113
118
|
print.newline();
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
continue;
|
|
117
122
|
}
|
|
118
123
|
|
|
119
|
-
maybe.indent(manyLines && noLeadingComment(property));
|
|
120
|
-
print(property);
|
|
121
|
-
|
|
122
|
-
if (property.isObjectMethod())
|
|
123
|
-
continue;
|
|
124
|
-
|
|
125
124
|
if (noTrailingComment(property) && !hasNextLeadingComment(property)) {
|
|
126
125
|
maybe.print.newline(manyLines);
|
|
127
126
|
maybe.print.linebreak(isNewlineBetweenSiblings(property));
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
129
|
|
|
130
|
+
indent.dec();
|
|
131
|
+
|
|
131
132
|
if (!insideNestedArrayCall) {
|
|
132
|
-
indent.dec();
|
|
133
133
|
maybe.indent(manyLines);
|
|
134
134
|
} else if (isInsideTupleLike(path)) {
|
|
135
|
-
indent.dec();
|
|
136
135
|
indent();
|
|
137
136
|
indent.inc();
|
|
138
137
|
}
|
package/lib/tokenize/is.js
CHANGED
|
@@ -209,4 +209,3 @@ export const hasTrailingComment = (path) => {
|
|
|
209
209
|
export const hasLeadingComment = (path) => path.node?.leadingComments?.length;
|
|
210
210
|
|
|
211
211
|
export const noTrailingComment = (path) => !path.node.trailingComments?.length;
|
|
212
|
-
export const noLeadingComment = (path) => !path.node.leadingComments?.length;
|
package/package.json
CHANGED