@putout/printer 2.44.0 → 2.45.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.07.04, v2.45.0
2
+
3
+ feature:
4
+ - d30c1cd @putout/printer: ObjectExpression: spread
5
+
1
6
  2023.07.03, v2.44.0
2
7
 
3
8
  feature:
@@ -12,6 +12,7 @@ const {
12
12
  } = require('../../is');
13
13
 
14
14
  const {parseComments} = require('../../comments');
15
+ const {isSpreadElement} = require('@babel/types');
15
16
 
16
17
  const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
17
18
  const isLogical = (path) => path.get('argument').isLogicalExpression();
@@ -101,6 +102,13 @@ function shouldAddNewline(path) {
101
102
  const ONE_LINE = true;
102
103
  const MANY_LINES = false;
103
104
 
105
+ const isSpreadFirst = (path) => {
106
+ const {properties} = path.node;
107
+ const {length} = properties;
108
+
109
+ return length > 1 && isSpreadElement(properties[0]);
110
+ };
111
+
104
112
  module.exports.isOneLine = isOneLine;
105
113
  function isOneLine(path) {
106
114
  const {length} = path.get('properties');
@@ -120,6 +128,9 @@ function isOneLine(path) {
120
128
  if (isCoupleLines(path))
121
129
  return MANY_LINES;
122
130
 
131
+ if (isSpreadFirst(path))
132
+ return MANY_LINES;
133
+
123
134
  return !isValue(path);
124
135
  }
125
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.44.0",
3
+ "version": "2.45.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",
@@ -47,6 +47,7 @@
47
47
  "generate"
48
48
  ],
49
49
  "devDependencies": {
50
+ "@babel/plugin-codemod-object-assign-to-object-spread": "^7.10.4",
50
51
  "@putout/plugin-minify": "^1.8.0",
51
52
  "@putout/plugin-printer": "^1.0.0",
52
53
  "@putout/plugin-react-hook-form": "^3.4.1",