@putout/printer 2.28.0 → 2.29.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.19, v2.29.0
2
+
3
+ feature:
4
+ - feb7c6a @putout/printer: ArrayExpression: String/String: tuple
5
+
1
6
  2023.06.19, v2.28.0
2
7
 
3
8
  feature:
@@ -84,6 +84,9 @@ module.exports.isNewlineBetweenElements = (path, {elements, maxElementsInOneLine
84
84
  if (isTwoStringsDifferentLength(elements))
85
85
  return ONE_LINE;
86
86
 
87
+ if (isShortTwoSimplesInsideObjectProperty(path, maxElementsInOneLine))
88
+ return ONE_LINE;
89
+
87
90
  if (isStringAndArray(elements))
88
91
  return ONE_LINE;
89
92
 
@@ -128,6 +131,30 @@ const isShortTwoSimplesInsideCall = (path, short) => {
128
131
  return length < short;
129
132
  };
130
133
 
134
+ const isShortTwoSimplesInsideObjectProperty = (path, short) => {
135
+ const {node, parentPath} = path;
136
+
137
+ const {elements} = node;
138
+ const {length} = elements;
139
+ const [a, b] = elements;
140
+
141
+ if (length > 2)
142
+ return false;
143
+
144
+ if (!parentPath.isObjectProperty())
145
+ return false;
146
+
147
+ if (!isStringLiteral(a) || !isStringLiteral(b))
148
+ return false;
149
+
150
+ if (looksLikeTuple(a, b))
151
+ return false;
152
+
153
+ return length < short;
154
+ };
155
+
156
+ const looksLikeTuple = (a, b) => b.value.length + 5 <= a.value.length * 2;
157
+
131
158
  function isOneSimple(path) {
132
159
  const elements = path.get('elements');
133
160
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.28.0",
3
+ "version": "2.29.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",