@putout/printer 14.3.6 → 14.4.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 +20 -0
- package/lib/json.js +2 -2
- package/lib/tokenize/comment/parse-trailing-comments.js +7 -1
- package/lib/tokenize/literals/string-literal.js +4 -12
- package/lib/tokenize/statements/expression-statement/expression-statement.js +25 -1
- package/package.json +11 -11
- package/tsconfig.json +2 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
2025.04.15, v14.4.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- c15e8d1 @putout/printer: json: string-literal
|
|
5
|
+
- fb50b99 @putout/printer: supertape v11.1.0
|
|
6
|
+
- 7e46e0a @putout/printer: samadhi v3.0.3
|
|
7
|
+
- d4222cf @putout/printer: putout v40.0.1
|
|
8
|
+
- f24d29d @putout/printer: goldstein v6.0.1
|
|
9
|
+
- 72a05df @putout/printer: estree-to-babel v11.0.2
|
|
10
|
+
- 36aefdf @putout/printer: check-dts v0.9.0
|
|
11
|
+
- bcb7a53 @putout/printer: @putout/plugin-react-hooks v8.0.1
|
|
12
|
+
- 809bfe2 @putout/printer: @putout/plugin-react-hook-form v6.0.0
|
|
13
|
+
- b5c91ec @putout/printer: @putout/plugin-promises v17.0.0
|
|
14
|
+
- 6c24426 @putout/printer: @putout/compare v17.0.0
|
|
15
|
+
|
|
16
|
+
2025.03.29, v14.3.7
|
|
17
|
+
|
|
18
|
+
fix:
|
|
19
|
+
- a73ce65 @putout/printer: ExpressionStatement: comments
|
|
20
|
+
|
|
1
21
|
2025.03.28, v14.3.6
|
|
2
22
|
|
|
3
23
|
fix:
|
package/lib/json.js
CHANGED
|
@@ -14,6 +14,7 @@ const {
|
|
|
14
14
|
isDecorator,
|
|
15
15
|
isMemberExpression,
|
|
16
16
|
isExpressionStatement,
|
|
17
|
+
isCallExpression,
|
|
17
18
|
} = types;
|
|
18
19
|
|
|
19
20
|
const hasBody = (path) => {
|
|
@@ -150,5 +151,10 @@ function isPrevCall(path) {
|
|
|
150
151
|
if (isExpressionStatement(prev))
|
|
151
152
|
return false;
|
|
152
153
|
|
|
153
|
-
|
|
154
|
+
const {expression} = path.node;
|
|
155
|
+
|
|
156
|
+
if (!isCallExpression(expression))
|
|
157
|
+
return false;
|
|
158
|
+
|
|
159
|
+
return !isCallExpression(expression.arguments[0]);
|
|
154
160
|
}
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports.StringLiteral = (path, {write}, semantics) => {
|
|
4
|
-
const {
|
|
4
|
+
const {value, raw = `'${value}'`} = path.node;
|
|
5
5
|
|
|
6
|
-
if (
|
|
6
|
+
if (path.parentPath.isJSXAttribute()) {
|
|
7
7
|
write(raw);
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
const value = raw.slice(1, -1);
|
|
13
|
-
write.quote();
|
|
14
|
-
write(maybeEscape(value, semantics));
|
|
15
|
-
write.quote();
|
|
16
|
-
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
11
|
+
const newValue = raw.slice(1, -1);
|
|
20
12
|
write.quote();
|
|
21
|
-
write(
|
|
13
|
+
write(maybeEscape(newValue, semantics));
|
|
22
14
|
write.quote();
|
|
23
15
|
};
|
|
24
16
|
|
|
@@ -15,6 +15,7 @@ const {
|
|
|
15
15
|
} = require('../../is');
|
|
16
16
|
|
|
17
17
|
const {isInsideAssignNextAssignFunction} = require('./is-inside-assign-next-assign-function');
|
|
18
|
+
const isCommentBlock = (a) => a?.type === 'CommentBlock';
|
|
18
19
|
|
|
19
20
|
const {
|
|
20
21
|
isCallExpression,
|
|
@@ -76,7 +77,11 @@ module.exports.ExpressionStatement = {
|
|
|
76
77
|
|
|
77
78
|
if (!insideReturn && shouldBreakline(path)) {
|
|
78
79
|
print.newline();
|
|
79
|
-
|
|
80
|
+
|
|
81
|
+
const condition = isNext(path)
|
|
82
|
+
&& noTrailingComment(path)
|
|
83
|
+
|| isNextToAssignmentCall(path)
|
|
84
|
+
|| isNextStatementWithBlockComment(path);
|
|
80
85
|
|
|
81
86
|
if (condition)
|
|
82
87
|
indent();
|
|
@@ -166,3 +171,22 @@ function isNextToAssignmentCall(path) {
|
|
|
166
171
|
|
|
167
172
|
return isCallExpression(expression);
|
|
168
173
|
}
|
|
174
|
+
|
|
175
|
+
function isNextStatementWithBlockComment(path) {
|
|
176
|
+
const {expression} = path.node;
|
|
177
|
+
|
|
178
|
+
if (!isCallExpression(expression))
|
|
179
|
+
return false;
|
|
180
|
+
|
|
181
|
+
if (!isCallExpression(expression.arguments[0]))
|
|
182
|
+
return false;
|
|
183
|
+
|
|
184
|
+
return hasTrailingBlock(path);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function hasTrailingBlock(path) {
|
|
188
|
+
const {trailingComments} = path.node;
|
|
189
|
+
const [first] = trailingComments;
|
|
190
|
+
|
|
191
|
+
return isCommentBlock(first);
|
|
192
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.4.0",
|
|
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",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@putout/babel": "^3.0.0",
|
|
36
|
-
"@putout/compare": "^
|
|
36
|
+
"@putout/compare": "^17.0.0",
|
|
37
37
|
"@putout/operate": "^13.0.0",
|
|
38
38
|
"@putout/operator-json": "^2.0.0",
|
|
39
39
|
"fullstore": "^3.0.0",
|
|
@@ -71,26 +71,26 @@
|
|
|
71
71
|
"@putout/eslint": "^4.1.0",
|
|
72
72
|
"@putout/plugin-minify": "^10.0.0",
|
|
73
73
|
"@putout/plugin-printer": "^5.0.0",
|
|
74
|
-
"@putout/plugin-promises": "^
|
|
75
|
-
"@putout/plugin-react-hook-form": "^
|
|
76
|
-
"@putout/plugin-react-hooks": "^
|
|
74
|
+
"@putout/plugin-promises": "^17.0.0",
|
|
75
|
+
"@putout/plugin-react-hook-form": "^6.0.0",
|
|
76
|
+
"@putout/plugin-react-hooks": "^8.0.1",
|
|
77
77
|
"acorn": "^8.8.2",
|
|
78
78
|
"c8": "^10.1.2",
|
|
79
|
-
"check-dts": "^0.
|
|
79
|
+
"check-dts": "^0.9.0",
|
|
80
80
|
"escover": "^4.0.1",
|
|
81
81
|
"eslint": "^9.0.0",
|
|
82
82
|
"eslint-plugin-putout": "^26.0.2",
|
|
83
|
-
"estree-to-babel": "^
|
|
84
|
-
"goldstein": "^
|
|
83
|
+
"estree-to-babel": "^11.0.2",
|
|
84
|
+
"goldstein": "^6.0.1",
|
|
85
85
|
"just-kebab-case": "^4.2.0",
|
|
86
86
|
"madrun": "^11.0.0",
|
|
87
87
|
"mock-require": "^3.0.3",
|
|
88
88
|
"montag": "^1.0.0",
|
|
89
89
|
"nodemon": "^3.0.1",
|
|
90
|
-
"putout": "^
|
|
90
|
+
"putout": "^40.0.1",
|
|
91
91
|
"redlint": "^4.0.0",
|
|
92
|
-
"samadhi": "^
|
|
93
|
-
"supertape": "^
|
|
92
|
+
"samadhi": "^3.0.3",
|
|
93
|
+
"supertape": "^11.1.0",
|
|
94
94
|
"try-catch": "^3.0.0",
|
|
95
95
|
"typescript": "^5.3.3"
|
|
96
96
|
},
|