@putout/printer 1.22.0 → 1.23.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
|
@@ -5,6 +5,7 @@ const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
|
5
5
|
const isLogical = (path) => path.get('argument').isLogicalExpression();
|
|
6
6
|
const isValue = (path) => path.get('properties.0.value').node;
|
|
7
7
|
const isIf = (path) => path.parentPath.parentPath.isIfStatement();
|
|
8
|
+
const isParentExpression = (path) => path.parentPath.isExpressionStatement();
|
|
8
9
|
|
|
9
10
|
const isForOf = (path) => {
|
|
10
11
|
if (path.parentPath.isForOfStatement())
|
|
@@ -18,7 +19,7 @@ module.exports.ObjectExpression = (path, {print, maybe, indent}) => {
|
|
|
18
19
|
|
|
19
20
|
const properties = path.get('properties');
|
|
20
21
|
const {length} = properties;
|
|
21
|
-
const parens =
|
|
22
|
+
const parens = isParens(path);
|
|
22
23
|
const manyLines = !isOneLine(path);
|
|
23
24
|
|
|
24
25
|
maybe.print(parens, '(');
|
|
@@ -102,3 +103,13 @@ function isOneLine(path) {
|
|
|
102
103
|
|
|
103
104
|
return !isValue(path);
|
|
104
105
|
}
|
|
106
|
+
|
|
107
|
+
function isParens(path) {
|
|
108
|
+
if (isBodyOfArrow(path))
|
|
109
|
+
return true;
|
|
110
|
+
|
|
111
|
+
if (isParentExpression(path))
|
|
112
|
+
return true;
|
|
113
|
+
|
|
114
|
+
return false;
|
|
115
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
|