@putout/printer 12.31.0 → 12.32.1
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/debug.js +2 -2
- package/lib/tokenize/expressions/array-expression/array-expression.js +10 -17
- package/lib/tokenize/expressions/array-expression/is-object-after-simple.js +6 -0
- package/lib/tokenize/is.js +2 -1
- package/lib/tokenize/statements/expression-statement/expression-statement.js +1 -1
- package/package.json +2 -1
- package/tsconfig.json +6 -0
package/ChangeLog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2025.02.15, v12.32.1
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- 1ae65ad @putout/printer: DEBUG -> LOG_DEBUG
|
|
5
|
+
|
|
6
|
+
2025.02.14, v12.32.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- bc351a1 @putout/printer: ArrayExpression: ObjectExpression between Identifier and CallExpression
|
|
10
|
+
|
|
1
11
|
2025.02.09, v12.31.0
|
|
2
12
|
|
|
3
13
|
feature:
|
package/lib/tokenize/debug.js
CHANGED
|
@@ -22,7 +22,10 @@ const {
|
|
|
22
22
|
isArrayIndented,
|
|
23
23
|
} = require('./indent');
|
|
24
24
|
|
|
25
|
-
const {
|
|
25
|
+
const {
|
|
26
|
+
isObjectAfterSimple,
|
|
27
|
+
isNextSimple,
|
|
28
|
+
} = require('./is-object-after-simple');
|
|
26
29
|
|
|
27
30
|
const {
|
|
28
31
|
isObjectExpression,
|
|
@@ -30,6 +33,7 @@ const {
|
|
|
30
33
|
isStringLiteral,
|
|
31
34
|
isIdentifier,
|
|
32
35
|
isFunction,
|
|
36
|
+
isCallExpression,
|
|
33
37
|
} = types;
|
|
34
38
|
|
|
35
39
|
const isNextString = (path) => isStringLiteral(path.getNextSibling());
|
|
@@ -60,18 +64,9 @@ const isSpreadBeforeObject = (a) => {
|
|
|
60
64
|
return prev.get('argument').isCallExpression();
|
|
61
65
|
};
|
|
62
66
|
|
|
63
|
-
const isNextSimple = (a) => {
|
|
64
|
-
const next = a.getNextSibling();
|
|
65
|
-
|
|
66
|
-
if (next.isSpreadElement())
|
|
67
|
-
return true;
|
|
68
|
-
|
|
69
|
-
return next.isIdentifier();
|
|
70
|
-
};
|
|
71
|
-
|
|
72
67
|
const isNextSimpleBetweenObjects = (a) => {
|
|
73
68
|
const next = a.getNextSibling();
|
|
74
|
-
const is = next.isSpreadElement() || next.isIdentifier();
|
|
69
|
+
const is = next.isSpreadElement() || next.isIdentifier() || next.isCallExpression();
|
|
75
70
|
|
|
76
71
|
if (!is)
|
|
77
72
|
return true;
|
|
@@ -115,8 +110,7 @@ module.exports.ArrayExpression = {
|
|
|
115
110
|
|
|
116
111
|
const indented = isArrayIndented(path);
|
|
117
112
|
|
|
118
|
-
|
|
119
|
-
maybe.indent.inc(shouldIncreaseIndent);
|
|
113
|
+
maybe.indent.inc(indented && shouldIncreaseIndent);
|
|
120
114
|
|
|
121
115
|
const isNewLine = isMultiLine(path, {
|
|
122
116
|
elements,
|
|
@@ -150,8 +144,7 @@ module.exports.ArrayExpression = {
|
|
|
150
144
|
}
|
|
151
145
|
}
|
|
152
146
|
|
|
153
|
-
|
|
154
|
-
maybe.indent.dec(shouldIncreaseIndent);
|
|
147
|
+
maybe.indent.dec(indented && shouldIncreaseIndent);
|
|
155
148
|
|
|
156
149
|
const parentElements = path.parentPath.get('elements');
|
|
157
150
|
|
|
@@ -166,7 +159,7 @@ module.exports.ArrayExpression = {
|
|
|
166
159
|
maybe.indent(elements.length && isNewLine);
|
|
167
160
|
}
|
|
168
161
|
|
|
169
|
-
if (isSimpleAndNotEmptyObject(elements) && !isSpreadElement(elements.at(-1))) {
|
|
162
|
+
if (isSimpleAndNotEmptyObject(elements) && !isSpreadElement(elements.at(-1)) && !isCallExpression(elements.at(-1))) {
|
|
170
163
|
print(',');
|
|
171
164
|
print.breakline();
|
|
172
165
|
}
|
|
@@ -196,7 +189,7 @@ module.exports.ArrayExpression = {
|
|
|
196
189
|
};
|
|
197
190
|
|
|
198
191
|
function isSimpleAfterObject(path) {
|
|
199
|
-
if (!isSpreadElement(path) && !isIdentifier(path))
|
|
192
|
+
if (!isSpreadElement(path) && !isIdentifier(path) && !isCallExpression(path))
|
|
200
193
|
return;
|
|
201
194
|
|
|
202
195
|
const prev = path.getPrevSibling();
|
package/lib/tokenize/is.js
CHANGED
|
@@ -77,7 +77,8 @@ function isStringAndIdentifier([a, b]) {
|
|
|
77
77
|
return isStringLiteral(a) && isIdentifier(b);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
module.exports.isSimpleAndNotEmptyObject = (
|
|
80
|
+
module.exports.isSimpleAndNotEmptyObject = (elements) => {
|
|
81
|
+
const [a, b] = elements;
|
|
81
82
|
const simpleTypes = [
|
|
82
83
|
'Identifier',
|
|
83
84
|
'SpreadElement',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.32.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@putout/eslint": "^3.5.0",
|
|
69
|
+
"@putout/eslint-flat": "^2.0.0",
|
|
69
70
|
"@putout/plugin-minify": "^9.0.0",
|
|
70
71
|
"@putout/plugin-printer": "^4.0.0",
|
|
71
72
|
"@putout/plugin-promises": "^16.0.0",
|