@putout/printer 13.2.0 → 13.4.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
+ 2025.03.13, v13.4.0
2
+
3
+ feature:
4
+ - abbfbce @putout/printer: improve support of ObjectExpressions inside ArrayExpressions
5
+
6
+ 2025.03.11, v13.3.0
7
+
8
+ feature:
9
+ - b4f00b3 @putout/printer: TSInterfaceDeclaration: couple extends
10
+
1
11
  2025.03.08, v13.2.0
2
12
 
3
13
  feature:
@@ -135,7 +135,7 @@ module.exports.ArrayExpression = {
135
135
  maybe.print(is, ',');
136
136
 
137
137
  if (!(isObjectExpression(element) && isObjectProperty(path.parentPath)))
138
- maybe.print.newline((is || isSpreadBeforeObject(element)) && !isNextObject(element));
138
+ maybe.print.newline((is || isSpreadBeforeObject(element)) && !isNextObject(element) && !isObjectExpression(element));
139
139
 
140
140
  maybe.print.space(is && isObjectAfterSimple(element));
141
141
 
@@ -4,18 +4,14 @@ const {types} = require('@putout/babel');
4
4
  const {
5
5
  isArrayExpression,
6
6
  isCallExpression,
7
+ isIdentifier,
7
8
  } = types;
8
9
 
9
- module.exports.isThirdObjectInsideArray = (path) => {
10
- const {parentPath} = path;
11
-
10
+ module.exports.isThirdObjectInsideArray = ({parentPath}) => {
12
11
  if (!isArrayExpression(parentPath))
13
12
  return false;
14
13
 
15
- const [, second, third] = parentPath.node.elements;
16
-
17
- if (!isCallExpression(second))
18
- return false;
14
+ const [, second] = parentPath.node.elements;
19
15
 
20
- return third === path.node;
16
+ return isCallExpression(second) && !!isIdentifier(second);
21
17
  };
@@ -53,10 +53,6 @@ function isInsideNestedArrayCall({parentPath}) {
53
53
 
54
54
  function isInsideNestedTuple({parentPath}) {
55
55
  const {elements} = parentPath.parentPath.node;
56
-
57
- if (!elements)
58
- return false;
59
-
60
56
  const [first] = elements;
61
57
 
62
58
  return isStringLiteral(first);
@@ -79,7 +79,8 @@ function isStringAndIdentifier([a, b]) {
79
79
  }
80
80
 
81
81
  module.exports.isSimpleAndNotEmptyObject = (elements) => {
82
- const [a, b] = elements;
82
+ let [a, b] = elements;
83
+
83
84
  const simpleTypes = [
84
85
  'Identifier',
85
86
  'SpreadElement',
@@ -91,6 +92,9 @@ module.exports.isSimpleAndNotEmptyObject = (elements) => {
91
92
  if (a && !simpleTypes.includes(a.type))
92
93
  return false;
93
94
 
95
+ if (!isObjectExpression(b))
96
+ b = elements.at(-1);
97
+
94
98
  if (!isObjectExpression(b))
95
99
  return false;
96
100
 
@@ -24,7 +24,14 @@ module.exports.TSInterfaceDeclaration = {
24
24
 
25
25
  if (node.extends) {
26
26
  print(' extends ');
27
- path.get('extends').map(print);
27
+
28
+ const extendsPaths = path.get('extends');
29
+ const n = extendsPaths.length - 1;
30
+
31
+ for (const [i, current] of extendsPaths.entries()) {
32
+ print(current);
33
+ maybe.print(i < n, ', ');
34
+ }
28
35
  }
29
36
 
30
37
  print('__typeParameters');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "13.2.0",
3
+ "version": "13.4.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",
@@ -69,7 +69,6 @@
69
69
  },
70
70
  "devDependencies": {
71
71
  "@putout/eslint": "^4.1.0",
72
- "@putout/eslint-flat": "^2.0.0",
73
72
  "@putout/plugin-minify": "^10.0.0",
74
73
  "@putout/plugin-printer": "^4.0.0",
75
74
  "@putout/plugin-promises": "^16.0.0",