@putout/printer 1.130.2 → 1.132.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,14 @@
1
+ 2023.06.04, v1.132.0
2
+
3
+ feature:
4
+ - b83ad0c @putout/printer: ArrayExpression: Tuple
5
+
6
+ 2023.06.03, v1.131.0
7
+
8
+ feature:
9
+ - 2647101 @putout/printer: ArrayExpression: new line when ObjectExpression
10
+ - 9af0bd8 @putout/printer: ImportAttributes: all cases
11
+
1
12
  2023.06.03, v1.130.2
2
13
 
3
14
  feature:
@@ -8,6 +8,7 @@ const {
8
8
  isArrayExpression,
9
9
  isIdentifier,
10
10
  isCallExpression,
11
+ isBooleanLiteral,
11
12
  } = require('@babel/types');
12
13
 
13
14
  const {isSimple} = require('@putout/operate');
@@ -24,6 +25,7 @@ const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
24
25
  const isIdentifierAndIdentifier = ([a, b]) => isIdentifier(a) && isIdentifier(b);
25
26
  const isInsideArray = (path) => path.parentPath.isArrayExpression();
26
27
  const isSimpleAndCall = ([a, b]) => isSimple(a) && isCallExpression(b);
28
+ const isBooleanAndSimple = ([a, b]) => isBooleanLiteral(a) && isSimple(b);
27
29
 
28
30
  const isTwoLongStrings = ([a, b]) => {
29
31
  const LONG_STRING = 20;
@@ -209,6 +211,9 @@ function isOneSimple(path) {
209
211
  }
210
212
 
211
213
  function isNewlineBetweenElements(path, {elements}) {
214
+ if (elements.length > 3)
215
+ return true;
216
+
212
217
  if (isOneSimple(path))
213
218
  return false;
214
219
 
@@ -227,6 +232,9 @@ function isNewlineBetweenElements(path, {elements}) {
227
232
  if (isInsideLoop(path))
228
233
  return false;
229
234
 
235
+ if (isBooleanAndSimple(elements))
236
+ return false;
237
+
230
238
  if (isSimpleAndCall(elements))
231
239
  return false;
232
240
 
@@ -5,7 +5,6 @@ const {
5
5
  exists,
6
6
  isNext,
7
7
  isLast,
8
-
9
8
  } = require('../../is');
10
9
 
11
10
  const {
@@ -24,7 +24,12 @@ module.exports.maybePrintAttributes = (path, {write, traverse}) => {
24
24
  });
25
25
  };
26
26
 
27
- const isAssertions = (path) => path.node.assertions.length;
27
+ const isAssertions = (path) => {
28
+ if (path.node.extra?.deprecatedAssertSyntax)
29
+ return true;
30
+
31
+ return path.node.assertions.length;
32
+ };
28
33
 
29
34
  function printAttributes(path, {write, traverse, type, keyword}) {
30
35
  const attributes = path.get(type);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.130.2",
3
+ "version": "1.132.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",