@putout/printer 18.1.4 → 18.1.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 +5 -0
- package/lib/tokenize/expressions/array-expression/array-expression.js +3 -3
- package/lib/tokenize/expressions/function/function-declaration.js +3 -3
- package/lib/tokenize/expressions/object-expression/object-expression.js +1 -4
- package/lib/tokenize/is.js +1 -1
- package/lib/tokenize/statements/expression-statement/expression-statement.js +4 -4
- package/lib/tokenize/statements/for-statement.js +2 -2
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
isStringAndArray,
|
|
8
8
|
isSimpleAndNotEmptyObject,
|
|
9
9
|
isNextObject,
|
|
10
|
-
|
|
10
|
+
callWithNext,
|
|
11
11
|
isInsideArray,
|
|
12
12
|
} from '#is';
|
|
13
13
|
import {
|
|
@@ -64,14 +64,14 @@ const isSpreadBeforeObject = (a) => {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
const isSimpleBetweenObjects = createTypeChecker([
|
|
67
|
-
['+',
|
|
67
|
+
['+', callWithNext(isObjectExpression)],
|
|
68
68
|
['-', isSpreadElement],
|
|
69
69
|
['-', isIdentifier],
|
|
70
70
|
['+: -> !', isCallExpression],
|
|
71
71
|
]);
|
|
72
72
|
|
|
73
73
|
const isSpaceAfterComa = createTypeChecker([
|
|
74
|
-
|
|
74
|
+
callWithNext(isSimpleBetweenObjects),
|
|
75
75
|
'+: -> !ObjectExpression',
|
|
76
76
|
]);
|
|
77
77
|
|
|
@@ -2,7 +2,7 @@ import {types} from '@putout/babel';
|
|
|
2
2
|
import {printParams} from '#print-params';
|
|
3
3
|
import {markAfter} from '#mark';
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
callWithNext,
|
|
6
6
|
isNext,
|
|
7
7
|
isNextParent,
|
|
8
8
|
} from '#is';
|
|
@@ -17,9 +17,9 @@ const {
|
|
|
17
17
|
const hasFnBody = ({node}) => node.body.body.length;
|
|
18
18
|
|
|
19
19
|
const isIndentAfter = createTypeChecker([
|
|
20
|
-
['+',
|
|
20
|
+
['+', callWithNext(isFunctionDeclaration)],
|
|
21
21
|
['+', isNext],
|
|
22
|
-
['-: -> !',
|
|
22
|
+
['-: -> !', callWithNext(isExpressionStatement)],
|
|
23
23
|
]);
|
|
24
24
|
|
|
25
25
|
const isNotInsideExportDefaultWithBody = createTypeChecker([
|
|
@@ -39,10 +39,7 @@ const {
|
|
|
39
39
|
|
|
40
40
|
const isLogicalArgument = (path) => isLogicalExpression(path.node.argument);
|
|
41
41
|
|
|
42
|
-
const isParens = createTypeChecker([
|
|
43
|
-
isInsideBody,
|
|
44
|
-
isInsideExpression,
|
|
45
|
-
]);
|
|
42
|
+
const isParens = createTypeChecker([isInsideBody, isInsideExpression]);
|
|
46
43
|
|
|
47
44
|
const getCallee = (fn) => (a) => fn(a.get('callee'));
|
|
48
45
|
|
package/lib/tokenize/is.js
CHANGED
|
@@ -30,7 +30,7 @@ export const isInsideTSModuleBlock = ({parentPath}) => isTSModuleBlock(parentPat
|
|
|
30
30
|
|
|
31
31
|
export const isInsideCall = ({parentPath}) => parentPath.isCallExpression();
|
|
32
32
|
export const isInsideReturn = ({parentPath}) => parentPath.isReturnStatement();
|
|
33
|
-
export const
|
|
33
|
+
export const callWithNext = (fn) => (path) => fn(path.getNextSibling());
|
|
34
34
|
|
|
35
35
|
export const isNext = (path) => {
|
|
36
36
|
const next = path.getNextSibling();
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
hasTrailingComment,
|
|
9
9
|
isCoupleLines,
|
|
10
10
|
isInsideReturn,
|
|
11
|
-
|
|
11
|
+
callWithNext,
|
|
12
12
|
hasLeadingComment,
|
|
13
13
|
} from '#is';
|
|
14
14
|
import {
|
|
@@ -27,7 +27,7 @@ const isCallInsideExpression = createTypeChecker([
|
|
|
27
27
|
|
|
28
28
|
const isNextToAssignmentCall = createTypeChecker([
|
|
29
29
|
'-: node.expression -> AssignmentExpression',
|
|
30
|
-
['+',
|
|
30
|
+
['+', callWithNext(isCallInsideExpression)],
|
|
31
31
|
]);
|
|
32
32
|
|
|
33
33
|
const isBreaklineAfter = createTypeChecker([
|
|
@@ -44,7 +44,7 @@ const isNextStatementWithBlockComment = createTypeChecker([
|
|
|
44
44
|
|
|
45
45
|
const isBreakline = createTypeChecker([
|
|
46
46
|
isNewlineBetweenSiblings,
|
|
47
|
-
|
|
47
|
+
callWithNext(isIfStatement),
|
|
48
48
|
]);
|
|
49
49
|
|
|
50
50
|
const isIndent = createTypeChecker([
|
|
@@ -55,7 +55,7 @@ const isIndent = createTypeChecker([
|
|
|
55
55
|
|
|
56
56
|
export const isIndentAfter = createTypeChecker([
|
|
57
57
|
'-: node.expression -> !AssignmentExpression',
|
|
58
|
-
['+',
|
|
58
|
+
['+', callWithNext(hasLeadingComment)],
|
|
59
59
|
]);
|
|
60
60
|
|
|
61
61
|
export const ExpressionStatement = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isInsideLabel,
|
|
3
3
|
exists,
|
|
4
|
-
|
|
4
|
+
callWithNext,
|
|
5
5
|
} from '#is';
|
|
6
6
|
import {markAfter} from '#mark';
|
|
7
7
|
|
|
@@ -40,7 +40,7 @@ export const ForStatement = {
|
|
|
40
40
|
print('__body');
|
|
41
41
|
maybe.indent.dec(is);
|
|
42
42
|
},
|
|
43
|
-
afterIf:
|
|
43
|
+
afterIf: callWithNext(exists),
|
|
44
44
|
after(path, {print}) {
|
|
45
45
|
print.linebreak();
|
|
46
46
|
markAfter(path);
|
package/package.json
CHANGED