@putout/printer 18.50.4 → 18.50.6
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 +10 -0
- package/lib/tokenize/expressions/array-pattern/array-pattern.js +1 -1
- package/lib/tokenize/expressions/binary-expression/maybe-inside-binary.js +1 -0
- package/lib/tokenize/expressions/member-expression/member-expressions.js +1 -1
- package/lib/tokenize/expressions/new-expression/new-expression.js +23 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -3,6 +3,7 @@ import {createTypeChecker} from '#type-checker';
|
|
|
3
3
|
const isInsideBinary = createTypeChecker([
|
|
4
4
|
'+: parentPath -> BinaryExpression',
|
|
5
5
|
'+: parentPath -> CallExpression',
|
|
6
|
+
'+: parentPath -> NewExpression',
|
|
6
7
|
]);
|
|
7
8
|
|
|
8
9
|
export const maybeInsideBinary = (fn) => (path, printer, semantics) => {
|
|
@@ -9,7 +9,7 @@ const isObjectInsideArrow = createTypeChecker([
|
|
|
9
9
|
]);
|
|
10
10
|
|
|
11
11
|
const isComputed = ({node}) => node.computed;
|
|
12
|
-
const isIntegerObject = ({node}) => /^\d+$/.test(node.object.
|
|
12
|
+
const isIntegerObject = ({node}) => /^\d+$/.test(node.object.raw);
|
|
13
13
|
|
|
14
14
|
const isIntegerLiteral = createTypeChecker([
|
|
15
15
|
['-', isComputed],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
2
|
import {maybeParens} from '#maybe-parens';
|
|
3
|
+
import {isConcatenation} from '#is-concatenation';
|
|
3
4
|
|
|
4
5
|
const {
|
|
5
6
|
isMemberExpression,
|
|
@@ -7,6 +8,7 @@ const {
|
|
|
7
8
|
} = types;
|
|
8
9
|
|
|
9
10
|
const isInsideMember = ({parentPath}) => isMemberExpression(parentPath);
|
|
11
|
+
const isMultiline = (path) => path.get('arguments').some(isConcatenation);
|
|
10
12
|
|
|
11
13
|
export const NewExpression = maybeParens({
|
|
12
14
|
print(path, printer, semantics) {
|
|
@@ -23,10 +25,30 @@ export const NewExpression = maybeParens({
|
|
|
23
25
|
maybePrintOpenBrace(path, printer, semantics);
|
|
24
26
|
|
|
25
27
|
const n = args.length - 1;
|
|
28
|
+
const multiline = isMultiline(path);
|
|
29
|
+
|
|
30
|
+
if (multiline)
|
|
31
|
+
printer.indent.inc();
|
|
26
32
|
|
|
27
33
|
for (const [i, arg] of args.entries()) {
|
|
34
|
+
maybe.print.breakline(multiline);
|
|
28
35
|
print(arg);
|
|
29
|
-
|
|
36
|
+
|
|
37
|
+
if (multiline) {
|
|
38
|
+
print(',');
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (i === n)
|
|
43
|
+
continue;
|
|
44
|
+
|
|
45
|
+
print(',');
|
|
46
|
+
print.space();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (multiline) {
|
|
50
|
+
printer.indent.dec();
|
|
51
|
+
print.breakline();
|
|
30
52
|
}
|
|
31
53
|
|
|
32
54
|
maybePrintCloseBrace(path, printer, semantics);
|
package/package.json
CHANGED