@putout/printer 1.148.0 → 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,13 @@
1
+ 2023.06.09, v1.149.0
2
+
3
+ feature:
4
+ - 35ec229 @putout/printer: ArrayExpression: plugins: couple lines
5
+
6
+ 2023.06.08, v1.148.1
7
+
8
+ feature:
9
+ - fe4b8f0 @putout/printer: ArrayExpression: plugins
10
+
1
11
  2023.06.08, v1.148.0
2
12
 
3
13
  fix:
@@ -25,7 +25,18 @@ const {
25
25
 
26
26
  const isForOf = ({parentPath}) => parentPath.isForOfStatement();
27
27
 
28
- const isStringAndArray = ([a, b]) => isStringLiteral(a) && isArrayExpression(b);
28
+ const isInsideOneElementArray = ({parentPath}) => parentPath.node.elements.length === 1;
29
+
30
+ const isStringAndArray = ([a, b]) => {
31
+ if (!isStringLiteral(a))
32
+ return false;
33
+
34
+ if (!isArrayExpression(b))
35
+ return false;
36
+
37
+ return !isStringAndIdentifier(b.node.elements);
38
+ };
39
+
29
40
  const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
30
41
  const isIdentifierAndIdentifier = ([a, b]) => isIdentifier(a) && isIdentifier(b);
31
42
  const isInsideArray = (path) => path.parentPath.isArrayExpression();
@@ -71,7 +82,7 @@ module.exports.ArrayExpression = {
71
82
  if (isCoupleLines(parentPath))
72
83
  return false;
73
84
 
74
- if (isStringAndIdentifier(elements))
85
+ if (isStringAndIdentifier(elements) && isInsideOneElementArray(path))
75
86
  return true;
76
87
 
77
88
  return isIdentifierAndIdentifier(elements);
@@ -133,7 +144,7 @@ module.exports.ArrayExpression = {
133
144
  if (isCoupleLines(parentPath))
134
145
  return false;
135
146
 
136
- if (isStringAndIdentifier(elements))
147
+ if (isStringAndIdentifier(elements) && isInsideOneElementArray(path))
137
148
  return true;
138
149
 
139
150
  return isIdentifierAndIdentifier(elements);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.148.0",
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",