@putout/printer 12.3.0 → 12.5.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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
4
|
+
const {isArrayExpression} = types;
|
|
5
|
+
|
|
6
|
+
const TYPES = [
|
|
7
|
+
'NullLiteral',
|
|
8
|
+
'NumericLiteral',
|
|
9
|
+
'BigIntLiteral',
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
module.exports.isInsideTuple = (path) => {
|
|
13
|
+
const {parentPath} = path;
|
|
14
|
+
|
|
15
|
+
if (!isArrayExpression(parentPath))
|
|
16
|
+
return false;
|
|
17
|
+
|
|
18
|
+
const [first, second] = parentPath.node.elements;
|
|
19
|
+
|
|
20
|
+
if (second !== path.node)
|
|
21
|
+
return false;
|
|
22
|
+
|
|
23
|
+
return TYPES.includes(first.type);
|
|
24
|
+
};
|
|
@@ -14,8 +14,12 @@ const {
|
|
|
14
14
|
|
|
15
15
|
const {parseComments} = require('../../comment/comment');
|
|
16
16
|
const {likeChain} = require('../member-expression/member-expressions');
|
|
17
|
+
const {isInsideTuple} = require('./is-inside-tuple');
|
|
17
18
|
|
|
18
|
-
const {
|
|
19
|
+
const {
|
|
20
|
+
isStringLiteral,
|
|
21
|
+
isArrayExpression,
|
|
22
|
+
} = types;
|
|
19
23
|
|
|
20
24
|
const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
21
25
|
const isLogical = (path) => path.get('argument').isLogicalExpression();
|
|
@@ -37,16 +41,19 @@ const isMemberExpressionCallee = ({parentPath}) => {
|
|
|
37
41
|
const isInsideCall = ({parentPath}) => parentPath.isCallExpression();
|
|
38
42
|
|
|
39
43
|
function isInsideNestedArrayCall({parentPath}) {
|
|
40
|
-
if (!
|
|
44
|
+
if (!isArrayExpression(parentPath))
|
|
41
45
|
return false;
|
|
42
46
|
|
|
43
|
-
if (!parentPath.parentPath
|
|
47
|
+
if (!isArrayExpression(parentPath.parentPath))
|
|
44
48
|
return false;
|
|
45
49
|
|
|
46
50
|
return isInsideCall(parentPath.parentPath);
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
function isInsideNestedTuple({parentPath}) {
|
|
54
|
+
if (!isArrayExpression(parentPath.parentPath))
|
|
55
|
+
return false;
|
|
56
|
+
|
|
50
57
|
const {elements} = parentPath.parentPath.node;
|
|
51
58
|
const [first] = elements;
|
|
52
59
|
|
|
@@ -61,7 +68,7 @@ module.exports.ObjectExpression = (path, printer, semantics) => {
|
|
|
61
68
|
indent,
|
|
62
69
|
} = printer;
|
|
63
70
|
|
|
64
|
-
const insideNestedArrayCall = isInsideNestedArrayCall(path);
|
|
71
|
+
const insideNestedArrayCall = isInsideTuple(path) || isInsideNestedArrayCall(path);
|
|
65
72
|
|
|
66
73
|
maybe.indent.inc(!insideNestedArrayCall);
|
|
67
74
|
|
package/package.json
CHANGED