@putout/printer 13.1.0 → 13.3.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,15 @@
1
+ 2025.03.11, v13.3.0
2
+
3
+ feature:
4
+ - b4f00b3 @putout/printer: TSInterfaceDeclaration: couple extends
5
+
6
+ 2025.03.08, v13.2.0
7
+
8
+ feature:
9
+ - 6a5607b @putout/printer: @putout/plugin-react-hooks v7.0.0
10
+ - b9c5048 @putout/printer: @putout/plugin-minify v10.0.0
11
+ - 87aed30 @putout/printer: third object in ArrayExpression
12
+
1
13
  2025.02.25, v13.1.0
2
14
 
3
15
  feature:
@@ -8,7 +8,7 @@ const {
8
8
  isStringAndArray,
9
9
  isSimpleAndNotEmptyObject,
10
10
  isNextObject,
11
- } = require('../../is');
11
+ } = require('#is');
12
12
 
13
13
  const {
14
14
  isIncreaseIndent,
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ const {types} = require('@putout/babel');
4
+ const {
5
+ isArrayExpression,
6
+ isCallExpression,
7
+ } = types;
8
+
9
+ module.exports.isThirdObjectInsideArray = (path) => {
10
+ const {parentPath} = path;
11
+
12
+ if (!isArrayExpression(parentPath))
13
+ return false;
14
+
15
+ const [, second, third] = parentPath.node.elements;
16
+
17
+ if (!isCallExpression(second))
18
+ return false;
19
+
20
+ return third === path.node;
21
+ };
@@ -15,6 +15,7 @@ const {
15
15
  const {parseComments} = require('../../comment/comment');
16
16
  const {isInsideTuple} = require('./is-inside-tuple');
17
17
  const {isLooksLikeChain} = require('../member-expression/is-looks-like-chain');
18
+ const {isThirdObjectInsideArray} = require('./is-third-object-inside-array');
18
19
 
19
20
  const {
20
21
  isStringLiteral,
@@ -52,6 +53,10 @@ function isInsideNestedArrayCall({parentPath}) {
52
53
 
53
54
  function isInsideNestedTuple({parentPath}) {
54
55
  const {elements} = parentPath.parentPath.node;
56
+
57
+ if (!elements)
58
+ return false;
59
+
55
60
  const [first] = elements;
56
61
 
57
62
  return isStringLiteral(first);
@@ -65,7 +70,7 @@ module.exports.ObjectExpression = (path, printer, semantics) => {
65
70
  indent,
66
71
  } = printer;
67
72
 
68
- const insideNestedArrayCall = isInsideTuple(path) || isInsideNestedArrayCall(path);
73
+ const insideNestedArrayCall = isInsideTuple(path) || isInsideNestedArrayCall(path) || isThirdObjectInsideArray(path);
69
74
 
70
75
  maybe.indent.inc(!insideNestedArrayCall);
71
76
 
@@ -56,18 +56,6 @@ module.exports.tokenize = (ast, overrides) => {
56
56
  });
57
57
  };
58
58
 
59
- const maybeIndent = (a) => a && indent();
60
- const maybeIndentInc = (a) => a && indent.inc();
61
- const maybeIndentDec = (a) => a && indent.dec();
62
- const maybeNewline = (a) => a && newline();
63
- const maybeBreakline = (a) => a && breakline();
64
- const maybeLinebreak = (a) => a && linebreak();
65
- const maybeWrite = (a, b) => a && write(b);
66
- const maybeSpace = (a) => a && space();
67
- let i = 0;
68
- const incIndent = () => ++i;
69
- const decIndent = () => --i;
70
-
71
59
  const indent = () => {
72
60
  addToken({
73
61
  type: TYPES.INDENT,
@@ -75,23 +63,36 @@ module.exports.tokenize = (ast, overrides) => {
75
63
  });
76
64
  };
77
65
 
78
- assign(indent, {
79
- inc: incIndent,
80
- dec: decIndent,
81
- });
66
+ const maybeIndent = (a) => a && indent();
82
67
 
83
- const splitter = () => {
68
+ const maybeIndentInc = (a) => a && indent.inc();
69
+
70
+ const maybeIndentDec = (a) => a && indent.dec();
71
+
72
+ const newline = () => {
84
73
  addToken({
85
- type: TYPES.SPLITTER,
86
- value: format.splitter,
74
+ type: TYPES.NEWLINE,
75
+ value: format.newline,
87
76
  });
88
77
  };
89
78
 
79
+ const maybeNewline = (a) => a && newline();
80
+
81
+ const breakline = () => {
82
+ newline();
83
+ indent();
84
+ };
85
+
86
+ const maybeBreakline = (a) => a && breakline();
87
+
90
88
  const linebreak = () => {
91
89
  indent();
92
90
  newline();
93
91
  };
94
92
 
93
+ const maybeLinebreak = (a) => a && linebreak();
94
+ const maybeWrite = (a, b) => a && write(b);
95
+
95
96
  const space = () => {
96
97
  addToken({
97
98
  type: TYPES.SPACE,
@@ -99,22 +100,27 @@ module.exports.tokenize = (ast, overrides) => {
99
100
  });
100
101
  };
101
102
 
102
- const breakline = () => {
103
- newline();
104
- indent();
105
- };
103
+ const maybeSpace = (a) => a && space();
104
+ let i = 0;
105
+ const incIndent = () => ++i;
106
+ const decIndent = () => --i;
106
107
 
107
- const quote = () => {
108
+ assign(indent, {
109
+ inc: incIndent,
110
+ dec: decIndent,
111
+ });
112
+
113
+ const splitter = () => {
108
114
  addToken({
109
- type: TYPES.QUOTE,
110
- value: format.quote,
115
+ type: TYPES.SPLITTER,
116
+ value: format.splitter,
111
117
  });
112
118
  };
113
119
 
114
- const newline = () => {
120
+ const quote = () => {
115
121
  addToken({
116
- type: TYPES.NEWLINE,
117
- value: format.newline,
122
+ type: TYPES.QUOTE,
123
+ value: format.quote,
118
124
  });
119
125
  };
120
126
 
@@ -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.1.0",
3
+ "version": "13.3.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",
@@ -62,16 +62,18 @@
62
62
  },
63
63
  "#test": {
64
64
  "default": "./test/create-test.js"
65
+ },
66
+ "#is": {
67
+ "default": "./lib/tokenize/is.js"
65
68
  }
66
69
  },
67
70
  "devDependencies": {
68
71
  "@putout/eslint": "^4.1.0",
69
- "@putout/eslint-flat": "^2.0.0",
70
- "@putout/plugin-minify": "^9.0.0",
72
+ "@putout/plugin-minify": "^10.0.0",
71
73
  "@putout/plugin-printer": "^4.0.0",
72
74
  "@putout/plugin-promises": "^16.0.0",
73
75
  "@putout/plugin-react-hook-form": "^5.0.0",
74
- "@putout/plugin-react-hooks": "^6.0.0",
76
+ "@putout/plugin-react-hooks": "^7.0.0",
75
77
  "acorn": "^8.8.2",
76
78
  "c8": "^10.1.2",
77
79
  "check-dts": "^0.8.0",