@putout/printer 6.11.3 → 6.11.4

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.12.01, v6.11.4
2
+
3
+ feature:
4
+ - d181e1c @putout/printer: ArrayExpression: notNumbersInsideForOf
5
+
1
6
  2023.12.01, v6.11.3
2
7
 
3
8
  feature:
@@ -12,6 +12,7 @@ const {
12
12
  isNullLiteral,
13
13
  isStringLiteral,
14
14
  isSpreadElement,
15
+ isNumericLiteral,
15
16
  } = require('@putout/babel').types;
16
17
 
17
18
  const {
@@ -22,7 +23,6 @@ const {
22
23
  isStringAndArray,
23
24
  isIdentifierAndIdentifier,
24
25
  satisfy,
25
-
26
26
  } = require('../../is');
27
27
 
28
28
  const {round} = Math;
@@ -89,12 +89,24 @@ module.exports.isMultiLine = (path, {elements, maxElementsInOneLine}) => {
89
89
  if (isStringAndString(elements) && isParentIsArrayWithFirstArrayElement(path))
90
90
  return ONE_LINE;
91
91
 
92
- if (tooLong(path) || isCoupleLines(path) || !isNumbers(elements) && !isForOf(path) && isLastArg(path) && !isParentProperty(path))
92
+ if (tooLong(path) || isCoupleLines(path))
93
+ return MULTI_LINE;
94
+
95
+ if (notNumbersInsideForOf(path))
93
96
  return MULTI_LINE;
94
97
 
95
98
  return ONE_LINE;
96
99
  };
97
100
 
101
+ function notNumbersInsideForOf(path) {
102
+ const {elements} = path.node;
103
+
104
+ if (isNumbers(elements))
105
+ return false;
106
+
107
+ return !isForOf(path) && isLastArg(path) && !isParentProperty(path);
108
+ }
109
+
98
110
  const isParentIsArrayWithFirstArrayElement = ({parentPath}) => {
99
111
  if (!isArrayExpression(parentPath))
100
112
  return false;
@@ -211,7 +223,7 @@ function isCallInsideArrow(path) {
211
223
 
212
224
  function isNumbers(elements) {
213
225
  for (const element of elements) {
214
- if (element.isNumericLiteral())
226
+ if (isNumericLiteral(element))
215
227
  return true;
216
228
  }
217
229
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "6.11.3",
3
+ "version": "6.11.4",
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",