@putout/printer 12.7.0 → 12.9.0
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
|
@@ -9,6 +9,7 @@ const {
|
|
|
9
9
|
|
|
10
10
|
const {markBefore} = require('../mark');
|
|
11
11
|
const {maybeInsideFn} = require('./maybe-inside-fn');
|
|
12
|
+
|
|
12
13
|
const {
|
|
13
14
|
isArrowFunctionExpression,
|
|
14
15
|
isObjectProperty,
|
|
@@ -151,4 +152,3 @@ module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics)
|
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
};
|
|
154
|
-
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
3
4
|
const {exists} = require('../../is');
|
|
4
5
|
const {isMarkedAfter} = require('../../mark');
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
isExpressionStatement,
|
|
9
|
+
isMemberExpression,
|
|
10
|
+
} = types;
|
|
11
|
+
|
|
12
|
+
const isInsideExpressionStatement = ({parentPath}) => isExpressionStatement(parentPath);
|
|
6
13
|
const notFirst = ({parentPath}) => exists(parentPath.getPrevSibling());
|
|
14
|
+
const isInsideMember = ({parentPath}) => isMemberExpression(parentPath);
|
|
7
15
|
|
|
8
16
|
const getPrev = ({parentPath}) => {
|
|
9
17
|
const prev = parentPath.getPrevSibling();
|
|
@@ -66,8 +74,9 @@ function maybePrintCloseBrace(path, printer, semantics) {
|
|
|
66
74
|
function maybePrintBrace(brace, path, printer, semantics) {
|
|
67
75
|
const {maybe, print} = printer;
|
|
68
76
|
const {roundBraces} = semantics;
|
|
77
|
+
const {length} = path.node.arguments;
|
|
69
78
|
|
|
70
|
-
if (path
|
|
79
|
+
if (length || isInsideMember(path))
|
|
71
80
|
return print(brace);
|
|
72
81
|
|
|
73
82
|
maybe.print(roundBraces.new, brace);
|
|
@@ -51,9 +51,6 @@ function isInsideNestedArrayCall({parentPath}) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function isInsideNestedTuple({parentPath}) {
|
|
54
|
-
if (!isArrayExpression(parentPath.parentPath))
|
|
55
|
-
return false;
|
|
56
|
-
|
|
57
54
|
const {elements} = parentPath.parentPath.node;
|
|
58
55
|
const [first] = elements;
|
|
59
56
|
|
|
@@ -119,7 +116,7 @@ module.exports.ObjectExpression = (path, printer, semantics) => {
|
|
|
119
116
|
if (!insideNestedArrayCall) {
|
|
120
117
|
indent.dec();
|
|
121
118
|
maybe.indent(manyLines);
|
|
122
|
-
} else if (isInsideNestedTuple(path)) {
|
|
119
|
+
} else if (isInsideTuple(path) || isInsideNestedTuple(path)) {
|
|
123
120
|
indent.dec();
|
|
124
121
|
indent();
|
|
125
122
|
indent.inc();
|
package/package.json
CHANGED