@putout/printer 18.0.4 → 18.0.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
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
2
|
import {markAfter} from '#mark';
|
|
3
|
+
import {createTypeChecker} from '#type-checker';
|
|
3
4
|
import {
|
|
4
5
|
exists,
|
|
5
6
|
isNext,
|
|
6
7
|
isInsideIf,
|
|
7
8
|
hasEmptyBody,
|
|
9
|
+
isInsideBlock,
|
|
8
10
|
} from '#is';
|
|
9
11
|
import {
|
|
10
12
|
printTrailingCommentBlock,
|
|
@@ -13,7 +15,6 @@ import {
|
|
|
13
15
|
|
|
14
16
|
const {
|
|
15
17
|
isBlockStatement,
|
|
16
|
-
isFunctionDeclaration,
|
|
17
18
|
isStatement,
|
|
18
19
|
isExpressionStatement,
|
|
19
20
|
isReturnStatement,
|
|
@@ -33,30 +34,22 @@ const isStatementNotExpression = (path) => {
|
|
|
33
34
|
return !isExpressionStatement(path);
|
|
34
35
|
};
|
|
35
36
|
|
|
37
|
+
const isInsideNestedBody = createTypeChecker([
|
|
38
|
+
['-: -> !', isInsideBlock],
|
|
39
|
+
'+: parentPath.parentPath -> BlockStatement',
|
|
40
|
+
]);
|
|
41
|
+
|
|
36
42
|
const isTopLevel = ({parentPath}) => parentPath.parentPath.isProgram();
|
|
37
43
|
const isEmptyConsequent = (path) => path.get('consequent').isEmptyStatement();
|
|
44
|
+
const isBlockConsequent = (path) => isBlockStatement(path.node.consequent);
|
|
45
|
+
const isConsequentHasBody = (path) => path.node.consequent.body.length;
|
|
38
46
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const isLastEmptyInsideBody = (path) => {
|
|
47
|
-
const {parentPath} = path;
|
|
48
|
-
|
|
49
|
-
if (!isBlockStatement(parentPath))
|
|
50
|
-
return false;
|
|
51
|
-
|
|
52
|
-
if (!isBlockStatement(path.node.consequent))
|
|
53
|
-
return false;
|
|
54
|
-
|
|
55
|
-
if (path.node.consequent.body.length)
|
|
56
|
-
return false;
|
|
57
|
-
|
|
58
|
-
return isFunctionDeclaration(path.parentPath.parentPath);
|
|
59
|
-
};
|
|
47
|
+
const isLastEmptyInsideBody = createTypeChecker([
|
|
48
|
+
['-: -> !', isInsideBlock],
|
|
49
|
+
['-: -> !', isBlockConsequent],
|
|
50
|
+
['-', isConsequentHasBody],
|
|
51
|
+
'+: parentPath.parentPath -> FunctionDeclaration',
|
|
52
|
+
]);
|
|
60
53
|
|
|
61
54
|
export const IfStatement = {
|
|
62
55
|
printTrailingCommentBlock,
|
package/package.json
CHANGED