@putout/printer 1.62.0 → 1.63.1

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
@@ -1,3 +1,13 @@
1
+ 2023.04.21, v1.63.1
2
+
3
+ feature:
4
+ - faf1596 @putout/printer: avoid newline between elements of ArrayExpression, when element is CallExpression
5
+
6
+ 2023.04.21, v1.63.0
7
+
8
+ feature:
9
+ - cceed23 @putout/printer: improve support of AssignmentPattern inside of ObjectProperty
10
+
1
11
  2023.04.20, v1.62.0
2
12
 
3
13
  feature:
@@ -7,6 +7,7 @@ const {
7
7
  isStringLiteral,
8
8
  isArrayExpression,
9
9
  isIdentifier,
10
+ isCallExpression,
10
11
  } = require('@babel/types');
11
12
 
12
13
  const {
@@ -21,7 +22,6 @@ const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
21
22
  const isIdentifierAndIdentifier = ([a, b]) => isIdentifier(a) && isIdentifier(b);
22
23
  const isArrayParent = (path) => path.parentPath.isArrayExpression();
23
24
 
24
- const isOneElementCall = (path, {elements}) => path.parentPath.isCallExpression() && elements.length === 1;
25
25
  const isTwoElementReturn = (path, {elements}) => path.parentPath.isReturnStatement() && elements.length === 2;
26
26
 
27
27
  const isTwoLongStrings = ([a, b]) => {
@@ -265,3 +265,13 @@ function isInsideLoop(path) {
265
265
 
266
266
  return true;
267
267
  }
268
+
269
+ const isOneElementCall = (path, {elements}) => {
270
+ if (!path.parentPath.isCallExpression())
271
+ return false;
272
+
273
+ if (elements.length !== 1)
274
+ return false;
275
+
276
+ return !isCallExpression(elements[0]);
277
+ };
@@ -9,6 +9,9 @@ module.exports.AssignmentPattern = (path, {print, maybe}) => {
9
9
  };
10
10
 
11
11
  function shouldPrint(path) {
12
+ if (path.parentPath.isObjectProperty() && !path.parentPath.node.shorthand)
13
+ return true;
14
+
12
15
  if (isArg(path))
13
16
  return true;
14
17
 
@@ -30,9 +30,7 @@ module.exports.ObjectPattern = (path, {indent, print, maybe}) => {
30
30
  if (!shorthand) {
31
31
  print(': ');
32
32
  print(valuePath);
33
- }
34
-
35
- if (isAssign)
33
+ } else if (isAssign)
36
34
  print(valuePath);
37
35
 
38
36
  if (is) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.62.0",
3
+ "version": "1.63.1",
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",