@putout/printer 18.1.0 → 18.1.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
CHANGED
|
@@ -12,7 +12,10 @@ const {
|
|
|
12
12
|
const isArgOfCall = (path) => path.parentPath?.isCallExpression() && path.parentPath.get('arguments.0') === path;
|
|
13
13
|
const isCall = (a) => a.type === 'CallExpression';
|
|
14
14
|
|
|
15
|
-
const isExcludedFromChain = satisfy([
|
|
15
|
+
const isExcludedFromChain = satisfy([
|
|
16
|
+
isUnaryExpression,
|
|
17
|
+
isIfStatement,
|
|
18
|
+
]);
|
|
16
19
|
const hasComment = ({type}) => type === 'CommentLine';
|
|
17
20
|
|
|
18
21
|
const isInsideMemberCall = (path) => {
|
|
@@ -38,7 +38,10 @@ const {
|
|
|
38
38
|
} = types;
|
|
39
39
|
|
|
40
40
|
const isLogicalArgument = (path) => isLogicalExpression(path.node.argument);
|
|
41
|
-
const isParens = createTypeChecker([
|
|
41
|
+
const isParens = createTypeChecker([
|
|
42
|
+
isInsideBody,
|
|
43
|
+
isInsideExpression,
|
|
44
|
+
]);
|
|
42
45
|
const getCallee = (fn) => (a) => fn(a.get('callee'));
|
|
43
46
|
|
|
44
47
|
const isMemberExpressionCallee = createTypeChecker([
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {types} from '@putout/babel';
|
|
1
2
|
import {createTypeChecker} from '#type-checker';
|
|
2
3
|
import {
|
|
3
4
|
isNext,
|
|
@@ -17,6 +18,8 @@ import {
|
|
|
17
18
|
import {afterIf} from './after-if.js';
|
|
18
19
|
import {beforeIf} from './before-if.js';
|
|
19
20
|
|
|
21
|
+
const {isIfStatement} = types;
|
|
22
|
+
|
|
20
23
|
const isCallInsideExpression = createTypeChecker([
|
|
21
24
|
'-: -> !ExpressionStatement',
|
|
22
25
|
'+: node.expression -> CallExpression',
|
|
@@ -27,23 +30,22 @@ const isNextToAssignmentCall = createTypeChecker([
|
|
|
27
30
|
['+', getNext(isCallInsideExpression)],
|
|
28
31
|
]);
|
|
29
32
|
|
|
30
|
-
const isNextStatementWithBlockComment = createTypeChecker([
|
|
31
|
-
'-: node.expression -> !CallExpression',
|
|
32
|
-
'-: node.expression.arguments.0 -> !CallExpression',
|
|
33
|
-
'+: node.trailingComments.0 -> CommentBlock',
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
33
|
const isBreaklineAfter = createTypeChecker([
|
|
37
34
|
['-: -> !', hasTrailingComment],
|
|
38
35
|
['-: -> !', isLast],
|
|
39
36
|
['+', isCoupleLines],
|
|
40
37
|
]);
|
|
41
38
|
|
|
42
|
-
const
|
|
43
|
-
.
|
|
44
|
-
.
|
|
39
|
+
const isNextStatementWithBlockComment = createTypeChecker([
|
|
40
|
+
'-: node.expression -> !CallExpression',
|
|
41
|
+
'-: node.expression.arguments.0 -> !CallExpression',
|
|
42
|
+
'+: node.trailingComments.0 -> CommentBlock',
|
|
43
|
+
]);
|
|
45
44
|
|
|
46
|
-
const isBreakline = createTypeChecker([
|
|
45
|
+
const isBreakline = createTypeChecker([
|
|
46
|
+
isNewlineBetweenSiblings,
|
|
47
|
+
getNext(isIfStatement),
|
|
48
|
+
]);
|
|
47
49
|
|
|
48
50
|
const isIndent = createTypeChecker([
|
|
49
51
|
noTrailingComment,
|
|
@@ -57,15 +59,15 @@ export const isIndentAfter = createTypeChecker([
|
|
|
57
59
|
]);
|
|
58
60
|
|
|
59
61
|
export const ExpressionStatement = {
|
|
62
|
+
printLeadingCommentLine,
|
|
63
|
+
printLeadingCommentBlock,
|
|
60
64
|
beforeIf,
|
|
61
65
|
before(path, {indent}) {
|
|
62
66
|
indent();
|
|
63
67
|
},
|
|
64
68
|
print(path, {print, maybe, store}) {
|
|
65
|
-
const insideReturn = isInsideReturn(path);
|
|
66
|
-
|
|
67
69
|
print('__expression');
|
|
68
|
-
maybe.print(!
|
|
70
|
+
maybe.print(!isInsideReturn(path), ';');
|
|
69
71
|
|
|
70
72
|
if (!isNext(path))
|
|
71
73
|
return;
|
|
@@ -88,5 +90,4 @@ export const ExpressionStatement = {
|
|
|
88
90
|
maybe.markAfter(store(), path);
|
|
89
91
|
},
|
|
90
92
|
};
|
|
91
|
-
|
|
92
|
-
ExpressionStatement.printLeadingCommentBlock = printLeadingCommentBlock;
|
|
93
|
+
|
package/package.json
CHANGED