@putout/printer 1.82.2 → 1.83.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,8 @@
1
+ 2023.05.08, v1.83.0
2
+
3
+ feature:
4
+ - 395584d @putout/printer: ArrayExpressions: newline
5
+
1
6
  2023.05.07, v1.82.2
2
7
 
3
8
  feature:
@@ -20,7 +20,8 @@ const SECOND = 1;
20
20
  const isStringAndArray = ([a, b]) => isStringLiteral(a) && isArrayExpression(b);
21
21
  const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
22
22
  const isIdentifierAndIdentifier = ([a, b]) => isIdentifier(a) && isIdentifier(b);
23
- const isArrayParent = (path) => path.parentPath.isArrayExpression();
23
+ const isInsideArray = (path) => path.parentPath.isArrayExpression();
24
+ const isStringAndCall = ([a, b]) => isStringLiteral(a) && isCallExpression(b);
24
25
 
25
26
  const isTwoLongStrings = ([a, b]) => {
26
27
  const LONG_STRING = 20;
@@ -83,7 +84,7 @@ module.exports.ArrayExpression = {
83
84
 
84
85
  const parentElements = path.parentPath.get('elements');
85
86
 
86
- if (isArrayParent(path) && isStringAndArray(parentElements)) {
87
+ if (isInsideArray(path) && isStringAndArray(parentElements)) {
87
88
  indent.dec();
88
89
  maybe.indent(elements.length && isNewLine);
89
90
  indent.inc();
@@ -220,6 +221,9 @@ function isNewlineBetweenElements(path, {elements}) {
220
221
  if (isInsideLoop(path))
221
222
  return false;
222
223
 
224
+ if (isStringAndCall(elements))
225
+ return false;
226
+
223
227
  if (isTwoStringsDifferentLength(elements))
224
228
  return false;
225
229
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.82.2",
3
+ "version": "1.83.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 fro 🐊Putout",