@putout/printer 8.19.0 → 8.20.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.04.23, v8.20.0
2
+
3
+ feature:
4
+ - 5a53f7e @putout/printer: ArrayExpression: array-object-identifier
5
+
1
6
  2024.04.19, v8.19.0
2
7
 
3
8
  feature:
@@ -7,8 +7,6 @@ const {
7
7
  isIdentifierAndIdentifier,
8
8
  isStringAndArray,
9
9
  isSimpleAndEmptyObject,
10
- isNext,
11
-
12
10
  } = require('../../is');
13
11
 
14
12
  const {
@@ -38,11 +36,18 @@ const isPrevObject = (a) => a.getPrevSibling().isObjectExpression();
38
36
  const isObjectAfterSpread = (a) => isSpreadElement(a) && isNextObject(a) && !isPrevObject(a);
39
37
  const isObjectAfterIdentifier = (a) => isIdentifier(a) && isNextObject(a) && !isPrevObject(a);
40
38
  const isObjectAfterSimple = (a) => isObjectAfterSpread(a) || isObjectAfterIdentifier(a);
41
- const isNextSpread = (a) => a.getNextSibling().isSpreadElement();
39
+ const isNextSimple = (a) => {
40
+ const next = a.getNextSibling();
41
+
42
+ if (next.isSpreadElement())
43
+ return true;
44
+
45
+ return next.isIdentifier();
46
+ };
42
47
 
43
- const isNextSpreadBetweenObjects = (a) => {
48
+ const isNextSimpleBetweenObjects = (a) => {
44
49
  const next = a.getNextSibling();
45
- const is = next.isSpreadElement();
50
+ const is = next.isSpreadElement() || next.isIdentifier();
46
51
 
47
52
  if (!is)
48
53
  return true;
@@ -101,7 +106,7 @@ module.exports.ArrayExpression = {
101
106
  for (const [index, element] of elements.entries()) {
102
107
  const is = isNewLine && isCurrentNewLine(element);
103
108
 
104
- if (isSpreadAfterObject(element))
109
+ if (isSimpleAfterObject(element))
105
110
  print.newline();
106
111
 
107
112
  maybe.indent(is);
@@ -116,7 +121,8 @@ module.exports.ArrayExpression = {
116
121
  if (!is && index < n) {
117
122
  print(',');
118
123
 
119
- if (isNextSpreadBetweenObjects(element) || !(element.isObjectExpression() && isNextSpread(element)))
124
+ if (isNextSimpleBetweenObjects(element) || !(element.isObjectExpression() && isNextSimple(element)))
125
+ //if (!(element.isObjectExpression() && isNextSimple(element)))
120
126
  print.space();
121
127
  }
122
128
  }
@@ -166,8 +172,8 @@ module.exports.ArrayExpression = {
166
172
  },
167
173
  };
168
174
 
169
- function isSpreadAfterObject(path) {
170
- if (!isSpreadElement(path))
175
+ function isSimpleAfterObject(path) {
176
+ if (!isSpreadElement(path) && !isIdentifier(path))
171
177
  return;
172
178
 
173
179
  const prev = path.getPrevSibling();
@@ -5,7 +5,6 @@ const {assign} = Object;
5
5
  module.exports.chain = (path) => {
6
6
  const all = [
7
7
  ...down(path),
8
-
9
8
  ...up(path),
10
9
  ];
11
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "8.19.0",
3
+ "version": "8.20.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",