@putout/printer 1.54.4 → 1.55.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 +13 -0
- package/lib/tokenize/expressions/array-expression.js +14 -0
- package/lib/tokenize/expressions/functions/function-declaration.js +0 -1
- package/lib/tokenize/statements/export-default-declaration.js +19 -1
- package/lib/tokenize/statements/for-of-statement.js +9 -11
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
2023.04.18, v1.55.0
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- 85dbbd1 @putout/printer: get back satisfy
|
|
5
|
+
|
|
6
|
+
feature:
|
|
7
|
+
- c540dcb @putout/printer: ForOfStatement: add support of Statement inside of body
|
|
8
|
+
|
|
9
|
+
2023.04.18, v1.54.5
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- 06bf3c0 @putout/printer: improve one element ArrayExpression newline support
|
|
13
|
+
|
|
1
14
|
2023.04.18, v1.54.4
|
|
2
15
|
|
|
3
16
|
fix:
|
|
@@ -186,7 +186,21 @@ function isCallInsideArrow(path) {
|
|
|
186
186
|
return path.node.elements.length < 4;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
function isOneSimple(path) {
|
|
190
|
+
const elements = path.get('elements');
|
|
191
|
+
|
|
192
|
+
if (elements.length !== 1)
|
|
193
|
+
return false;
|
|
194
|
+
|
|
195
|
+
const [first] = elements;
|
|
196
|
+
|
|
197
|
+
return first.isIdentifier() && first.node.name.length < 5;
|
|
198
|
+
}
|
|
199
|
+
|
|
189
200
|
function isNewlineBetweenElements(path, {elements}) {
|
|
201
|
+
if (isOneSimple(path))
|
|
202
|
+
return false;
|
|
203
|
+
|
|
190
204
|
if (isCallInsideArrow(path))
|
|
191
205
|
return false;
|
|
192
206
|
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
isNewlineBetweenStatements,
|
|
5
|
+
isNext,
|
|
6
|
+
} = require('../is');
|
|
7
|
+
|
|
4
8
|
const {isMarkedAfter} = require('../mark');
|
|
5
9
|
|
|
10
|
+
const notClass = (path) => {
|
|
11
|
+
if (!isNext(path))
|
|
12
|
+
return false;
|
|
13
|
+
|
|
14
|
+
return !path.get('declaration').isClass();
|
|
15
|
+
};
|
|
16
|
+
|
|
6
17
|
module.exports.ExportDefaultDeclaration = {
|
|
7
18
|
beforeIf(path) {
|
|
8
19
|
const prev = path.getPrevSibling();
|
|
@@ -21,4 +32,11 @@ module.exports.ExportDefaultDeclaration = {
|
|
|
21
32
|
traverse(declaration);
|
|
22
33
|
maybe.print(!declaration.isClassDeclaration(), ';');
|
|
23
34
|
},
|
|
35
|
+
afterSatisfy: () => [
|
|
36
|
+
notClass,
|
|
37
|
+
],
|
|
38
|
+
after(path, {print}) {
|
|
39
|
+
print.newline();
|
|
40
|
+
print.newline();
|
|
41
|
+
},
|
|
24
42
|
};
|
|
@@ -31,21 +31,19 @@ module.exports.ForOfStatement = {
|
|
|
31
31
|
|
|
32
32
|
const bodyPath = path.get('body');
|
|
33
33
|
|
|
34
|
-
if (bodyPath.isExpressionStatement()) {
|
|
35
|
-
indent.inc();
|
|
36
|
-
print.newline();
|
|
37
|
-
traverse(bodyPath);
|
|
38
|
-
maybe.markAfter(isMarkedAfter(bodyPath), path);
|
|
39
|
-
indent.dec();
|
|
40
|
-
maybe.print.newline(isNext(path));
|
|
41
|
-
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
34
|
if (bodyPath.isBlockStatement()) {
|
|
46
35
|
print(' ');
|
|
47
36
|
print('__body');
|
|
37
|
+
|
|
38
|
+
return;
|
|
48
39
|
}
|
|
40
|
+
|
|
41
|
+
indent.inc();
|
|
42
|
+
print.newline();
|
|
43
|
+
traverse(bodyPath);
|
|
44
|
+
indent.dec();
|
|
45
|
+
|
|
46
|
+
maybe.markAfter(isMarkedAfter(bodyPath), path);
|
|
49
47
|
},
|
|
50
48
|
afterIf: isNext,
|
|
51
49
|
after(path, {print}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.55.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
|