@putout/printer 8.26.0 → 8.27.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
@@ -1,3 +1,8 @@
1
+ 2024.05.02, v8.27.0
2
+
3
+ feature:
4
+ - 20b3eac @putout/printer: ArrayExpression: nested array: space
5
+
1
6
  2024.05.01, v8.26.0
2
7
 
3
8
  feature:
@@ -26,6 +26,7 @@ const {
26
26
  isSpreadElement,
27
27
  isStringLiteral,
28
28
  isIdentifier,
29
+ isArrayExpression,
29
30
  } = types;
30
31
 
31
32
  const isNextString = (path) => isStringLiteral(path.getNextSibling());
@@ -35,7 +36,20 @@ const isNextObject = (a) => a.getNextSibling().isObjectExpression();
35
36
  const isPrevObject = (a) => a.getPrevSibling().isObjectExpression();
36
37
  const isObjectAfterSpread = (a) => isSpreadElement(a) && isNextObject(a) && !isPrevObject(a);
37
38
  const isObjectAfterIdentifier = (a) => isIdentifier(a) && isNextObject(a) && !isPrevObject(a);
38
- const isObjectAfterSimple = (a) => isObjectAfterSpread(a) || isObjectAfterIdentifier(a);
39
+
40
+ const isObjectAfterArray = (a) => {
41
+ if (!isArrayExpression(a))
42
+ return false;
43
+
44
+ return isNextObject(a);
45
+ };
46
+
47
+ const isObjectAfterSimple = (a) => {
48
+ if (isObjectAfterArray(a))
49
+ return true;
50
+
51
+ return isObjectAfterSpread(a) || isObjectAfterIdentifier(a);
52
+ };
39
53
 
40
54
  const isSpreadBeforeObject = (a) => {
41
55
  if (!a.isObjectExpression())
@@ -64,7 +64,7 @@ function isStringAndIdentifier([a, b]) {
64
64
  }
65
65
 
66
66
  module.exports.isSimpleAndEmptyObject = ([a, b]) => {
67
- if (!isIdentifier(a) && !isSpreadElement(a))
67
+ if (!isIdentifier(a) && !isSpreadElement(a) && !isArrayExpression(a))
68
68
  return false;
69
69
 
70
70
  if (!isObjectExpression(b))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "8.26.0",
3
+ "version": "8.27.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",