@putout/printer 5.0.0 → 5.1.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
|
@@ -70,6 +70,7 @@ const isExcludedFromChain = satisfy([
|
|
|
70
70
|
isIfStatement,
|
|
71
71
|
]);
|
|
72
72
|
|
|
73
|
+
module.exports.likeChain = likeChain;
|
|
73
74
|
function likeChain(path) {
|
|
74
75
|
const [root, properties] = chain(path);
|
|
75
76
|
|
|
@@ -82,9 +83,8 @@ function likeChain(path) {
|
|
|
82
83
|
if (calls.length === 2 && !firstCall.name)
|
|
83
84
|
return false;
|
|
84
85
|
|
|
85
|
-
if (isArgOfCall(path))
|
|
86
|
+
if (isArgOfCall(path))
|
|
86
87
|
return false;
|
|
87
|
-
}
|
|
88
88
|
|
|
89
89
|
return calls.length > 1;
|
|
90
90
|
}
|
|
@@ -12,12 +12,25 @@ const {
|
|
|
12
12
|
} = require('../../is');
|
|
13
13
|
|
|
14
14
|
const {parseComments} = require('../../comment/comment');
|
|
15
|
+
const {likeChain} = require('../member-expression/member-expressions');
|
|
15
16
|
|
|
16
17
|
const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
17
18
|
const isLogical = (path) => path.get('argument').isLogicalExpression();
|
|
18
19
|
const isValue = (path) => path.get('properties.0.value').node;
|
|
19
20
|
const isParentExpression = (path) => path.parentPath.isExpressionStatement();
|
|
20
21
|
|
|
22
|
+
const isMemberExpressionCallee = ({parentPath}) => {
|
|
23
|
+
if (!parentPath.isCallExpression())
|
|
24
|
+
return false;
|
|
25
|
+
|
|
26
|
+
const callee = parentPath.get('callee');
|
|
27
|
+
|
|
28
|
+
if (!callee.isMemberExpression())
|
|
29
|
+
return false;
|
|
30
|
+
|
|
31
|
+
return likeChain(callee);
|
|
32
|
+
};
|
|
33
|
+
|
|
21
34
|
module.exports.ObjectExpression = (path, {print, maybe, indent, write}, semantics) => {
|
|
22
35
|
const {trailingComma} = semantics;
|
|
23
36
|
indent.inc();
|
|
@@ -34,6 +47,8 @@ module.exports.ObjectExpression = (path, {print, maybe, indent, write}, semantic
|
|
|
34
47
|
|
|
35
48
|
const n = properties.length - 1;
|
|
36
49
|
|
|
50
|
+
maybe.indent.inc(isMemberExpressionCallee(path));
|
|
51
|
+
|
|
37
52
|
for (const [index, property] of properties.entries()) {
|
|
38
53
|
if (property.isSpreadElement()) {
|
|
39
54
|
const logical = isLogical(property);
|
|
@@ -68,6 +83,8 @@ module.exports.ObjectExpression = (path, {print, maybe, indent, write}, semantic
|
|
|
68
83
|
maybe.indent(manyLines);
|
|
69
84
|
print('}');
|
|
70
85
|
maybe.print(parens, ')');
|
|
86
|
+
|
|
87
|
+
maybe.indent.dec(isMemberExpressionCallee(path));
|
|
71
88
|
};
|
|
72
89
|
|
|
73
90
|
const hasNextLeadingComment = (path) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"escover": "^3.0.0",
|
|
57
57
|
"eslint": "^8.0.1",
|
|
58
58
|
"eslint-plugin-n": "^16.0.0",
|
|
59
|
-
"eslint-plugin-putout": "^
|
|
59
|
+
"eslint-plugin-putout": "^20.0.0",
|
|
60
60
|
"estree-to-babel": "^7.0.0",
|
|
61
61
|
"just-kebab-case": "^4.2.0",
|
|
62
62
|
"madrun": "^9.0.0",
|