@putout/printer 18.2.10 → 18.2.12

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,14 @@
1
+ 2026.03.08, v18.2.12
2
+
3
+ feature:
4
+ - 284d9a7 @putout/printer: ArrayExpression: isNewlineAfterComma: simplify
5
+
6
+ 2026.03.08, v18.2.11
7
+
8
+ feature:
9
+ - b16bb59 @putout/printer: ArrayExpression: newline: isNewlineAfterComma
10
+ - 5f0e329 @putout/printer: @putout/plugin-minify v12.0.0
11
+
1
12
  2026.03.08, v18.2.10
2
13
 
3
14
  feature:
@@ -5,13 +5,13 @@ import {
5
5
  isStringAndIdentifier,
6
6
  isIdentifierAndIdentifier,
7
7
  isSimpleAndNotEmptyObject,
8
- isNextObject,
9
8
  callWithNext,
10
9
  callWithPrev,
11
10
  } from '#is';
12
11
  import {
13
12
  isCurrentNewLine,
14
13
  isMultiLine,
14
+ isNewlineAfterComma,
15
15
  } from './newline.js';
16
16
  import {isObjectAfterSimple} from './is-object-after-simple.js';
17
17
  import {
@@ -27,35 +27,9 @@ const {
27
27
  isObjectExpression,
28
28
  isSpreadElement,
29
29
  isIdentifier,
30
- isFunction,
31
30
  isCallExpression,
32
- isObjectProperty,
33
31
  } = types;
34
32
 
35
- const isSpreadBeforeObject = (a) => {
36
- if (!a.isObjectExpression())
37
- return false;
38
-
39
- const prev = a.getPrevSibling();
40
-
41
- if (!prev.isSpreadElement())
42
- return false;
43
-
44
- const argCall = prev.get('argument');
45
-
46
- if (argCall.isCallExpression()) {
47
- const [first] = argCall.get('arguments');
48
-
49
- if (isFunction(first))
50
- return false;
51
- }
52
-
53
- if (prev.getPrevSibling().isObjectExpression())
54
- return false;
55
-
56
- return prev.get('argument').isCallExpression();
57
- };
58
-
59
33
  const isSimpleBetweenObjects = createTypeChecker([
60
34
  ['+', callWithNext(isObjectExpression)],
61
35
  ['-', isSpreadElement],
@@ -112,8 +86,8 @@ export const ArrayExpression = {
112
86
  if (index < n || trailingComma)
113
87
  maybe.print(is, ',');
114
88
 
115
- if (!(isObjectExpression(element) && isObjectProperty(path.parentPath)))
116
- maybe.print.newline((is || isSpreadBeforeObject(element)) && !isNextObject(element) && !isObjectExpression(element));
89
+ if (needsNewline && isNewlineAfterComma(element))
90
+ print.newline();
117
91
 
118
92
  maybe.print.space(is && isObjectAfterSimple(element));
119
93
 
@@ -5,6 +5,10 @@ import {
5
5
  isInsideCall,
6
6
  isStringAndArray,
7
7
  } from '#is';
8
+ import {
9
+ isNeedsNewlineOption,
10
+ isNeedsToHideIndentOption,
11
+ } from './is.js';
8
12
 
9
13
  const isTwoLongStrings = (path) => {
10
14
  const [a, b] = path.node.elements;
@@ -104,9 +108,6 @@ export const isHideIndent = createTypeChecker([
104
108
 
105
109
  const isLastElementObjectExpression = ({node}) => isObjectExpression(node.elements.at(-1));
106
110
 
107
- const isNeedsNewlineOption = (a, {needsNewline}) => needsNewline;
108
- const isNeedsToHideIndentOption = (a, {needsToHideIndent}) => needsToHideIndent;
109
-
110
111
  export const isSecondIndent = createTypeChecker([
111
112
  ['-: -> !', isNeedsNewlineOption],
112
113
  ['+', isNeedsToHideIndentOption],
@@ -0,0 +1,3 @@
1
+ export const isNeedsNewlineOption = (a, {needsNewline}) => needsNewline;
2
+
3
+ export const isNeedsToHideIndentOption = (a, {needsToHideIndent}) => needsToHideIndent;
@@ -11,6 +11,7 @@ import {
11
11
  isSimpleAndNotEmptyObject,
12
12
  isInsideCall,
13
13
  isInsideArray,
14
+ callWithNext,
14
15
  } from '#is';
15
16
  import {isIncreaseIndent} from './indent.js';
16
17
 
@@ -309,3 +310,8 @@ export const isCurrentNewLine = createTypeChecker([
309
310
  '+: -> SpreadElement',
310
311
  '+: -> !ObjectExpression',
311
312
  ]);
313
+
314
+ export const isNewlineAfterComma = createTypeChecker([
315
+ ['-', callWithNext(isObjectExpression)],
316
+ ['+: -> !ObjectExpression'],
317
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.2.10",
3
+ "version": "18.2.12",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
@@ -74,7 +74,6 @@
74
74
  "@babel/parser": "^7.28.5",
75
75
  "@putout/eslint": "^6.0.0",
76
76
  "@putout/eslint-flat": "^4.0.0",
77
- "@putout/plugin-minify": "^11.2.1",
78
77
  "@putout/plugin-printer": "^8.0.0",
79
78
  "@putout/plugin-promises": "^19.0.0",
80
79
  "@putout/plugin-react-hook-form": "^6.0.0",