@putout/printer 1.148.1 → 1.149.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.06.09, v1.149.0
2
+
3
+ feature:
4
+ - 35ec229 @putout/printer: ArrayExpression: plugins: couple lines
5
+
1
6
  2023.06.08, v1.148.1
2
7
 
3
8
  feature:
@@ -25,6 +25,8 @@ const {
25
25
 
26
26
  const isForOf = ({parentPath}) => parentPath.isForOfStatement();
27
27
 
28
+ const isInsideOneElementArray = ({parentPath}) => parentPath.node.elements.length === 1;
29
+
28
30
  const isStringAndArray = ([a, b]) => {
29
31
  if (!isStringLiteral(a))
30
32
  return false;
@@ -34,6 +36,7 @@ const isStringAndArray = ([a, b]) => {
34
36
 
35
37
  return !isStringAndIdentifier(b.node.elements);
36
38
  };
39
+
37
40
  const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
38
41
  const isIdentifierAndIdentifier = ([a, b]) => isIdentifier(a) && isIdentifier(b);
39
42
  const isInsideArray = (path) => path.parentPath.isArrayExpression();
@@ -79,7 +82,7 @@ module.exports.ArrayExpression = {
79
82
  if (isCoupleLines(parentPath))
80
83
  return false;
81
84
 
82
- if (isStringAndIdentifier(elements))
85
+ if (isStringAndIdentifier(elements) && isInsideOneElementArray(path))
83
86
  return true;
84
87
 
85
88
  return isIdentifierAndIdentifier(elements);
@@ -141,7 +144,7 @@ module.exports.ArrayExpression = {
141
144
  if (isCoupleLines(parentPath))
142
145
  return false;
143
146
 
144
- if (isStringAndIdentifier(elements))
147
+ if (isStringAndIdentifier(elements) && isInsideOneElementArray(path))
145
148
  return true;
146
149
 
147
150
  return isIdentifierAndIdentifier(elements);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.148.1",
3
+ "version": "1.149.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",