@putout/printer 15.1.2 → 15.2.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,13 @@
1
+ 2025.06.13, v15.2.0
2
+
3
+ feature:
4
+ - 348901a @putout/printer: ArrayExpression: maxElementsOneLine: 0
5
+
6
+ 2025.06.12, v15.1.3
7
+
8
+ fix:
9
+ - f70a8d7 @putout/printer: VariableDeclaration: empty declarations
10
+
1
11
  2025.06.12, v15.1.2
2
12
 
3
13
  fix:
@@ -60,7 +60,12 @@ const isSiblingIsArray = (path) => {
60
60
  };
61
61
 
62
62
  module.exports.isMultiLine = (path, {elements, maxElementsInOneLine}) => {
63
- if (elements.length > 3 && !isObjectExpression(elements[0]))
63
+ const [first] = elements;
64
+
65
+ if (elements.length > maxElementsInOneLine && isStringLiteral(first))
66
+ return MULTI_LINE;
67
+
68
+ if (elements.length > 3 && !isObjectExpression(first))
64
69
  return MULTI_LINE;
65
70
 
66
71
  if (isSimpleAndNotEmptyObject(elements))
@@ -133,7 +138,7 @@ const isForOf = ({parentPath}) => parentPath.isForOfStatement();
133
138
 
134
139
  const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
135
140
 
136
- const isShortTwoSimplesInsideCall = (path, short) => {
141
+ const isShortTwoSimplesInsideCall = (path, maxElementsInOneLine) => {
137
142
  const {node, parentPath} = path;
138
143
 
139
144
  const {elements} = node;
@@ -146,7 +151,7 @@ const isShortTwoSimplesInsideCall = (path, short) => {
146
151
  if (!isStringLiteral(a) || !isStringLiteral(b))
147
152
  return false;
148
153
 
149
- return length < short;
154
+ return length < maxElementsInOneLine;
150
155
  };
151
156
 
152
157
  const isTwoSimplesInsideObjectProperty = (path) => {
@@ -15,22 +15,22 @@ const {maybeTypeAnnotation} = require('../../maybe/maybe-type-annotation');
15
15
  const {moreThenMaxPropertiesLengthInOneLine} = require('./more-then-max-properties-length-in-one-line');
16
16
  const {printKey} = require('../object-expression/print-key');
17
17
 
18
- const isInsideFn = (path) => {
19
- if (isFunction(path.parentPath))
20
- return true;
21
-
22
- return isFunction(path.parentPath.parentPath);
23
- };
24
-
25
18
  const {
19
+ isObjectExpression,
26
20
  isIdentifier,
27
- isObjectPattern,
28
21
  isAssignmentPattern,
29
- isObjectExpression,
30
22
  isVariableDeclarator,
31
23
  isFunction,
24
+ isObjectPattern,
32
25
  } = types;
33
26
 
27
+ const isInsideFn = (path) => {
28
+ if (isFunction(path.parentPath))
29
+ return true;
30
+
31
+ return isFunction(path.parentPath.parentPath);
32
+ };
33
+
34
34
  function isIndent(path) {
35
35
  return !path.parentPath.isArrayPattern();
36
36
  }
@@ -2,6 +2,10 @@
2
2
 
3
3
  module.exports.maybeSpaceAfterKeyword = (path, {write}) => {
4
4
  const {declarations} = path.node;
5
+
6
+ if (!declarations.length)
7
+ return;
8
+
5
9
  const {id} = declarations[0];
6
10
 
7
11
  if (id.type === 'ArrayPattern' || id.type === 'ObjectPattern')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "15.1.2",
3
+ "version": "15.2.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",
package/tsconfig.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "moduleResolution": "nodenext",
3
4
  "target": "es2015",
4
5
  "skipLibCheck": true
5
6
  },