@putout/printer 18.1.3 → 18.1.5

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,13 @@
1
+ 2026.03.07, v18.1.5
2
+
3
+ feature:
4
+ - 142e7b8 @putout/printer: is: getNext -> callWithNext
5
+
6
+ 2026.03.06, v18.1.4
7
+
8
+ fix:
9
+ - 27872ca @putout/printer: ArrayExpression: newline: string and object
10
+
1
11
  2026.03.06, v18.1.3
2
12
 
3
13
  fix:
@@ -7,7 +7,7 @@ import {
7
7
  isStringAndArray,
8
8
  isSimpleAndNotEmptyObject,
9
9
  isNextObject,
10
- getNext,
10
+ callWithNext,
11
11
  isInsideArray,
12
12
  } from '#is';
13
13
  import {
@@ -64,14 +64,14 @@ const isSpreadBeforeObject = (a) => {
64
64
  };
65
65
 
66
66
  const isSimpleBetweenObjects = createTypeChecker([
67
- ['+', getNext(isObjectExpression)],
67
+ ['+', callWithNext(isObjectExpression)],
68
68
  ['-', isSpreadElement],
69
69
  ['-', isIdentifier],
70
70
  ['+: -> !', isCallExpression],
71
71
  ]);
72
72
 
73
73
  const isSpaceAfterComa = createTypeChecker([
74
- getNext(isSimpleBetweenObjects),
74
+ callWithNext(isSimpleBetweenObjects),
75
75
  '+: -> !ObjectExpression',
76
76
  ]);
77
77
 
@@ -160,9 +160,17 @@ const isMoreThenMaxIdentifierLength = (path, {maxElementLengthInOneLine}) => {
160
160
  return first.name.length > maxElementLengthInOneLine;
161
161
  };
162
162
 
163
+ const hasObjects = (path) => {
164
+ const {elements} = path.node;
165
+ const literals = elements.filter(isObjectExpression);
166
+
167
+ return literals.length;
168
+ };
169
+
163
170
  const isMoreThenMaxElementLengthInOneLine = createTypeChecker([
164
171
  ['-', isEmptyArray],
165
172
  ['-: -> !', isInsideCall],
173
+ ['-', hasObjects],
166
174
  ['+', isMoreThenMaxLiteralLength],
167
175
  ['+', isMoreThenMaxIdentifierLength],
168
176
  ]);
@@ -2,7 +2,7 @@ import {types} from '@putout/babel';
2
2
  import {printParams} from '#print-params';
3
3
  import {markAfter} from '#mark';
4
4
  import {
5
- getNext,
5
+ callWithNext,
6
6
  isNext,
7
7
  isNextParent,
8
8
  } from '#is';
@@ -17,9 +17,9 @@ const {
17
17
  const hasFnBody = ({node}) => node.body.body.length;
18
18
 
19
19
  const isIndentAfter = createTypeChecker([
20
- ['+', getNext(isFunctionDeclaration)],
20
+ ['+', callWithNext(isFunctionDeclaration)],
21
21
  ['+', isNext],
22
- ['-: -> !', getNext(isExpressionStatement)],
22
+ ['-: -> !', callWithNext(isExpressionStatement)],
23
23
  ]);
24
24
 
25
25
  const isNotInsideExportDefaultWithBody = createTypeChecker([
@@ -39,10 +39,7 @@ const {
39
39
 
40
40
  const isLogicalArgument = (path) => isLogicalExpression(path.node.argument);
41
41
 
42
- const isParens = createTypeChecker([
43
- isInsideBody,
44
- isInsideExpression,
45
- ]);
42
+ const isParens = createTypeChecker([isInsideBody, isInsideExpression]);
46
43
 
47
44
  const getCallee = (fn) => (a) => fn(a.get('callee'));
48
45
 
@@ -30,7 +30,7 @@ export const isInsideTSModuleBlock = ({parentPath}) => isTSModuleBlock(parentPat
30
30
 
31
31
  export const isInsideCall = ({parentPath}) => parentPath.isCallExpression();
32
32
  export const isInsideReturn = ({parentPath}) => parentPath.isReturnStatement();
33
- export const getNext = (fn) => (path) => fn(path.getNextSibling());
33
+ export const callWithNext = (fn) => (path) => fn(path.getNextSibling());
34
34
 
35
35
  export const isNext = (path) => {
36
36
  const next = path.getNextSibling();
@@ -8,7 +8,7 @@ import {
8
8
  hasTrailingComment,
9
9
  isCoupleLines,
10
10
  isInsideReturn,
11
- getNext,
11
+ callWithNext,
12
12
  hasLeadingComment,
13
13
  } from '#is';
14
14
  import {
@@ -27,7 +27,7 @@ const isCallInsideExpression = createTypeChecker([
27
27
 
28
28
  const isNextToAssignmentCall = createTypeChecker([
29
29
  '-: node.expression -> AssignmentExpression',
30
- ['+', getNext(isCallInsideExpression)],
30
+ ['+', callWithNext(isCallInsideExpression)],
31
31
  ]);
32
32
 
33
33
  const isBreaklineAfter = createTypeChecker([
@@ -44,7 +44,7 @@ const isNextStatementWithBlockComment = createTypeChecker([
44
44
 
45
45
  const isBreakline = createTypeChecker([
46
46
  isNewlineBetweenSiblings,
47
- getNext(isIfStatement),
47
+ callWithNext(isIfStatement),
48
48
  ]);
49
49
 
50
50
  const isIndent = createTypeChecker([
@@ -55,7 +55,7 @@ const isIndent = createTypeChecker([
55
55
 
56
56
  export const isIndentAfter = createTypeChecker([
57
57
  '-: node.expression -> !AssignmentExpression',
58
- ['+', getNext(hasLeadingComment)],
58
+ ['+', callWithNext(hasLeadingComment)],
59
59
  ]);
60
60
 
61
61
  export const ExpressionStatement = {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isInsideLabel,
3
3
  exists,
4
- getNext,
4
+ callWithNext,
5
5
  } from '#is';
6
6
  import {markAfter} from '#mark';
7
7
 
@@ -40,7 +40,7 @@ export const ForStatement = {
40
40
  print('__body');
41
41
  maybe.indent.dec(is);
42
42
  },
43
- afterIf: getNext(exists),
43
+ afterIf: callWithNext(exists),
44
44
  after(path, {print}) {
45
45
  print.linebreak();
46
46
  markAfter(path);
@@ -1,7 +1,7 @@
1
1
  import {createTuple} from './create-tuple.js';
2
2
 
3
- const {isArray} = Array;
4
3
  const isString = (a) => typeof a === 'string';
4
+ const {isArray} = Array;
5
5
 
6
6
  export const parseOperation = (operation) => {
7
7
  const [result, command] = operation.split(':');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.1.3",
3
+ "version": "18.1.5",
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",