@putout/printer 1.49.1 → 1.50.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,11 @@
1
+ 2023.04.14, v1.50.0
2
+
3
+ fix:
4
+ - 6203f72 @putout/printer: ArrayExpression: one element CallExpression
5
+
6
+ feature:
7
+ - 491126f @putout/printer: ArrayExpression: two elements ReturnStatement: no newline
8
+
1
9
  2023.04.14, v1.49.1
2
10
 
3
11
  fix:
@@ -21,6 +21,9 @@ const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
21
21
  const isIdentifierAndIdentifier = ([a, b]) => isIdentifier(a) && isIdentifier(b);
22
22
  const isArrayParent = (path) => path.parentPath.isArrayExpression();
23
23
 
24
+ const isOneElementCall = (path, {elements}) => path.parentPath.isCallExpression() && elements.length === 1;
25
+ const isTwoElementReturn = (path, {elements}) => path.parentPath.isReturnStatement() && elements.length === 2;
26
+
24
27
  const isTwoLongStrings = ([a, b]) => {
25
28
  const LONG_STRING = 20;
26
29
 
@@ -172,10 +175,13 @@ function tooLong(path) {
172
175
  }
173
176
 
174
177
  function isNewlineBetweenElements(path, {elements}) {
175
- if (isIncreaseIndent(path))
178
+ if (isTwoElementReturn(path, {elements}))
176
179
  return false;
177
180
 
178
- if (isInsideCallLoop(path))
181
+ if (isOneElementCall(path, {elements}))
182
+ return false;
183
+
184
+ if (isIncreaseIndent(path))
179
185
  return false;
180
186
 
181
187
  if (isInsideLoop(path))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.49.1",
3
+ "version": "1.50.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",