@putout/printer 2.13.1 → 2.14.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
+ 2023.06.14, v2.14.0
2
+
3
+ feature:
4
+ - 0f3dbaf @putout/printer: ArrayExpression: no newline when one element with type SpreadElement
5
+
1
6
  2023.06.14, v2.13.1
2
7
 
3
8
  fix:
@@ -11,6 +11,7 @@ const {
11
11
  isBooleanLiteral,
12
12
  isNullLiteral,
13
13
  isStringLiteral,
14
+ isSpreadElement,
14
15
  } = require('@babel/types');
15
16
 
16
17
  const {
@@ -24,6 +25,15 @@ const {
24
25
 
25
26
  const {round} = Math;
26
27
 
28
+ const isOneSpread = (elements) => {
29
+ if (elements.length > 1)
30
+ return false;
31
+
32
+ const [first] = elements;
33
+
34
+ return isSpreadElement(first);
35
+ };
36
+
27
37
  const isSimpleAndCall = ([a, b]) => {
28
38
  if (!isSimple(a))
29
39
  return;
@@ -44,6 +54,9 @@ module.exports.isNewlineBetweenElements = (path, {elements, maxElementsInOneLine
44
54
  if (isOneSimple(path))
45
55
  return ONE_LINE;
46
56
 
57
+ if (isOneSpread(elements))
58
+ return ONE_LINE;
59
+
47
60
  if (elements.length === 2 && isIdentifierAndIdentifier(elements))
48
61
  return ONE_LINE;
49
62
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.13.1",
3
+ "version": "2.14.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",