@putout/printer 8.12.1 → 8.13.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.11, v8.13.0
2
+
3
+ feature:
4
+ - 454c659 @putout/printer: ArrayExpression: SpreadElement, ObjectExpression
5
+
1
6
  2024.04.11, v8.12.1
2
7
 
3
8
  feature:
@@ -6,7 +6,7 @@ const {
6
6
  isStringAndIdentifier,
7
7
  isIdentifierAndIdentifier,
8
8
  isStringAndArray,
9
- isIdentifierAndObject,
9
+ isSimpleAndEmptyObject,
10
10
  } = require('../../is');
11
11
 
12
12
  const {
@@ -116,7 +116,7 @@ module.exports.ArrayExpression = {
116
116
  maybe.indent(elements.length && isNewLine);
117
117
  }
118
118
 
119
- if (isIdentifierAndObject(elements)) {
119
+ if (isSimpleAndEmptyObject(elements)) {
120
120
  print(',');
121
121
  print.breakline();
122
122
  }
@@ -21,7 +21,7 @@ const {
21
21
  isCoupleLines,
22
22
  isStringAndArray,
23
23
  isIdentifierAndIdentifier,
24
- isIdentifierAndObject,
24
+ isSimpleAndEmptyObject,
25
25
  } = require('../../is');
26
26
 
27
27
  const {round} = Math;
@@ -61,7 +61,7 @@ module.exports.isMultiLine = (path, {elements, maxElementsInOneLine}) => {
61
61
  if (elements.length > 3 && !isObjectExpression(elements[0]))
62
62
  return MULTI_LINE;
63
63
 
64
- if (isIdentifierAndObject(elements))
64
+ if (isSimpleAndEmptyObject(elements))
65
65
  return MULTI_LINE;
66
66
 
67
67
  if (isOneSimple(path))
@@ -1,8 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const {types} = require('@putout/babel');
4
- const {isIdentifier} = types;
5
-
6
3
  const {
7
4
  isCoupleLines,
8
5
  isForOf,
@@ -1,7 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isStringLiteral,
6
+ isSpreadElement,
5
7
  isIdentifier,
6
8
  isIfStatement,
7
9
  isStatement,
@@ -10,7 +12,7 @@ const {
10
12
  isMemberExpression,
11
13
  isArrayExpression,
12
14
  isObjectExpression,
13
- } = require('@putout/babel').types;
15
+ } = types;
14
16
 
15
17
  const isParentProgram = (path) => path.parentPath?.isProgram();
16
18
  const isParentBlock = (path) => path.parentPath.isBlockStatement();
@@ -61,8 +63,8 @@ function isStringAndIdentifier([a, b]) {
61
63
  return isStringLiteral(a) && isIdentifier(b);
62
64
  }
63
65
 
64
- module.exports.isIdentifierAndObject = ([a, b]) => {
65
- if (!isIdentifier(a))
66
+ module.exports.isSimpleAndEmptyObject = ([a, b]) => {
67
+ if (!isIdentifier(a) && !isSpreadElement(a))
66
68
  return false;
67
69
 
68
70
  if (!isObjectExpression(b))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "8.12.1",
3
+ "version": "8.13.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",