@putout/printer 1.25.1 → 1.27.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
+ 2023.04.07, v1.27.0
2
+
3
+ feature:
4
+ - 6afc4de @putout/printer: ArrayExpression: add support of string, string tuple
5
+
6
+ 2023.04.06, v1.26.0
7
+
8
+ feature:
9
+ - 3ad5aab @putout/printer: prevent indent infinite loop
10
+
1
11
  2023.04.06, v1.25.1
2
12
 
3
13
  feature:
@@ -16,6 +16,7 @@ const {
16
16
  const isForOf = ({parentPath}) => parentPath.isForOfStatement();
17
17
  const SECOND = 1;
18
18
  const isStringAndArray = ([a, b]) => isStringLiteral(a) && isArrayExpression(b);
19
+ const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
19
20
  const isArrayParent = (path) => path.parentPath.isArrayExpression();
20
21
 
21
22
  const isTwoLongStrings = ([a, b]) => {
@@ -58,6 +59,7 @@ module.exports.ArrayExpression = {
58
59
  const isNewLine = isNewlineBetweenElements(path, {
59
60
  elements,
60
61
  });
62
+
61
63
  const n = elements.length - 1;
62
64
 
63
65
  maybe.print.newline(isNewLine && elements.length);
@@ -180,6 +182,9 @@ function isNewlineBetweenElements(path, {elements}) {
180
182
  if (isStringAndIdentifier(elements))
181
183
  return false;
182
184
 
185
+ if (isStringAndString(elements) && path.parentPath.isArrayExpression() && isArrayExpression(path.parentPath.node.elements[0]))
186
+ return false;
187
+
183
188
  if (tooLong(path) || isCoupleLines(path) || !isNumbers(elements) && !isForOf(path) && isLastArg(path) && !isParentProperty(path))
184
189
  return true;
185
190
 
@@ -197,6 +202,7 @@ function isTwoStringsDifferentLength(strings) {
197
202
 
198
203
  const aLength = a
199
204
  .node.value.length;
205
+
200
206
  const bLength = b
201
207
  .node.value.length;
202
208
 
@@ -215,7 +215,7 @@ function printIndent(i, indent) {
215
215
  let result = '';
216
216
  ++i;
217
217
 
218
- while (--i) {
218
+ while (--i > 0) {
219
219
  result += indent;
220
220
  }
221
221
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.25.1",
3
+ "version": "1.27.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",