@putout/printer 18.50.1 → 18.50.3
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,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {createTypeChecker} from '#type-checker';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const isInsideBinary = createTypeChecker([
|
|
4
|
+
'+: parentPath -> BinaryExpression',
|
|
5
|
+
'+: parentPath -> CallExpression',
|
|
6
|
+
]);
|
|
5
7
|
|
|
6
8
|
export const maybeInsideBinary = (fn) => (path, printer, semantics) => {
|
|
7
9
|
const {indent, print} = printer;
|
|
@@ -2,6 +2,7 @@ import {types} from '@putout/babel';
|
|
|
2
2
|
import {isInsideCall} from '#is';
|
|
3
3
|
import {maybeParens} from '#maybe-parens';
|
|
4
4
|
import {createTypeChecker} from '#type-checker';
|
|
5
|
+
import {isConcatenation} from '#is-concatenation';
|
|
5
6
|
|
|
6
7
|
const isLast = (arg) => {
|
|
7
8
|
const {length} = arg.parentPath.node.arguments;
|
|
@@ -46,6 +47,7 @@ const callWithSomeArg = (fn) => (path) => parseArgs(path).some(fn);
|
|
|
46
47
|
|
|
47
48
|
const isMultiline = createTypeChecker([
|
|
48
49
|
['+', callWithSomeArg(isMemberCallee)],
|
|
50
|
+
['+', callWithSomeArg(isConcatenation)],
|
|
49
51
|
['-: -> !', tooLong],
|
|
50
52
|
['+', isInsideCall],
|
|
51
53
|
]);
|
|
@@ -66,20 +68,30 @@ export const CallExpression = maybeParens((path, printer, semantics) => {
|
|
|
66
68
|
|
|
67
69
|
export const OptionalCallExpression = CallExpression;
|
|
68
70
|
|
|
69
|
-
const isSpaceBeforeArg = createTypeChecker([
|
|
70
|
-
['-: parentPath -> !', isMaxArgs],
|
|
71
|
-
['+: -> ArrayExpression'],
|
|
72
|
-
]);
|
|
73
|
-
|
|
74
71
|
const isFilledArray = createTypeChecker([
|
|
75
72
|
'-: -> !ArrayExpression',
|
|
76
73
|
'+: node.elements.length -> +',
|
|
77
74
|
]);
|
|
78
75
|
|
|
76
|
+
const isFirstArg = (arg) => !arg.__putout_printer_index;
|
|
77
|
+
|
|
78
|
+
const isSpaceBeforeFilledArray = createTypeChecker([
|
|
79
|
+
['-', isFirstArg],
|
|
80
|
+
['-: -> !', isFilledArray],
|
|
81
|
+
['+: parentPath', isMultiline],
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
const isSpaceBeforeArg = createTypeChecker([
|
|
85
|
+
['+', isSpaceBeforeFilledArray],
|
|
86
|
+
['-: parentPath -> !', isMaxArgs],
|
|
87
|
+
['+: -> ArrayExpression'],
|
|
88
|
+
]);
|
|
89
|
+
|
|
79
90
|
const isBreaklineBeforeArg = createTypeChecker([
|
|
80
91
|
['-', isFilledArray],
|
|
81
92
|
['+: parentPath', isMaxArgs],
|
|
82
93
|
['+', isMemberCallee],
|
|
94
|
+
['+', isConcatenation],
|
|
83
95
|
['-: parentPath -> !', isMultiline],
|
|
84
96
|
['+: parentPath.node.arguments.length', '>', 1],
|
|
85
97
|
]);
|
|
@@ -87,6 +99,7 @@ const isBreaklineBeforeArg = createTypeChecker([
|
|
|
87
99
|
const isCommaAfterArg = createTypeChecker([
|
|
88
100
|
['+: -> !', isLast],
|
|
89
101
|
['+', isMemberCallee],
|
|
102
|
+
['+', isConcatenation],
|
|
90
103
|
['+: parentPath', isMaxArgs],
|
|
91
104
|
['-: parentPath.node.arguments.length', '<=', 1],
|
|
92
105
|
['+: parentPath', isMultiline],
|
|
@@ -94,6 +107,7 @@ const isCommaAfterArg = createTypeChecker([
|
|
|
94
107
|
|
|
95
108
|
const isBreaklineAfterAllArgs = createTypeChecker([
|
|
96
109
|
['+', isMaxArgs],
|
|
110
|
+
['+', callWithSomeArg(isConcatenation)],
|
|
97
111
|
['-: -> !', isMultiline],
|
|
98
112
|
['+: node.arguments.length', '>', 1],
|
|
99
113
|
['+', getFirstArg(isMemberCallee)],
|
package/package.json
CHANGED