@putout/printer 14.7.2 → 14.8.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.05.26, v14.8.0
2
+
3
+ feature:
4
+ - 1d87093 @putout/printer: eslint-plugin-putout v27.0.0
5
+ - 6b3ea67 @putout/printer: ExportDeclaration: trailingComma
6
+ - fa15bb1 @putout/printer: ObjectExpression: ObjectMethod: trailingComma
7
+
8
+ 2025.05.23, v14.7.3
9
+
10
+ feature:
11
+ - f32d6cd ReturnStatement: inside LabeledStatement
12
+
1
13
  2025.05.03, v14.7.2
2
14
 
3
15
  feature:
@@ -181,3 +181,4 @@ function isParens(path) {
181
181
 
182
182
  return isParentExpression(path);
183
183
  }
184
+
@@ -49,6 +49,7 @@ const parentIfWithoutElse = ({parentPath}) => {
49
49
 
50
50
  module.exports.BlockStatement = {
51
51
  print(path, printer, semantics) {
52
+ const {trailingComma} = semantics;
52
53
  const {
53
54
  indent,
54
55
  maybe,
@@ -93,8 +94,10 @@ module.exports.BlockStatement = {
93
94
 
94
95
  maybe.indent.dec(callInsideChain);
95
96
 
96
- if (path.parentPath.isObjectMethod())
97
- write(',');
97
+ const {parentPath} = path;
98
+
99
+ if (isObjectMethod(parentPath))
100
+ maybe.write(isNext(parentPath) || trailingComma, ',');
98
101
  },
99
102
  afterIf: shouldAddNewlineAfter,
100
103
  after(path, {write}) {
@@ -193,3 +196,4 @@ function isTry({parentPath}) {
193
196
 
194
197
  return parentPath.parentPath?.isTryStatement();
195
198
  }
199
+
@@ -39,7 +39,8 @@ module.exports.ExportNamespaceSpecifier = (path, {print}) => {
39
39
  };
40
40
 
41
41
  module.exports.ExportNamedDeclaration = {
42
- print(path, {print, traverse, indent, maybe}) {
42
+ print(path, {print, traverse, indent, maybe}, semantics) {
43
+ const {trailingComma} = semantics;
43
44
  const {exportKind} = path.node;
44
45
  const specifiers = path.get('specifiers');
45
46
  const {maxOneLineSpecifiers} = options.exports;
@@ -77,14 +78,17 @@ module.exports.ExportNamedDeclaration = {
77
78
 
78
79
  for (const [i, spec] of specifiers.entries()) {
79
80
  const isType = spec.node.exportKind === 'type';
81
+ const isLast = i < lastIndex;
82
+
80
83
  maybe.indent(isNewline);
81
84
  maybe.print(isType, 'type ');
82
85
  traverse(spec);
83
86
 
84
- if (i < lastIndex && !isNewline)
87
+ if (isLast && !isNewline)
85
88
  print(', ');
89
+ else if (isNewline)
90
+ maybe.print(isLast || trailingComma, ',');
86
91
 
87
- maybe.print(isNewline, ',');
88
92
  maybe.print.newline(isNewline);
89
93
  }
90
94
 
@@ -144,4 +144,3 @@ module.exports.ImportDeclaration.printTrailingCommentBlock = (path, printer, sem
144
144
  maybe.print.breakline(!isExportDeclaration(next));
145
145
  printComment();
146
146
  };
147
-
@@ -2,6 +2,7 @@
2
2
 
3
3
  const {types} = require('@putout/babel');
4
4
 
5
+ const {isInsideLabel} = require('#is');
5
6
  const {
6
7
  isPrevBody,
7
8
  noTrailingComment,
@@ -10,6 +11,7 @@ const {
10
11
 
11
12
  const {hasPrevNewline} = require('../../mark');
12
13
  const {maybeSpaceAfterKeyword} = require('./maybe-space-after-keyword');
14
+
13
15
  const {isJSXElement} = types;
14
16
  const isBodyLength = ({parentPath}) => parentPath.node?.body?.length > 2;
15
17
 
@@ -23,9 +25,9 @@ module.exports.ReturnStatement = {
23
25
  print.linebreak();
24
26
  },
25
27
  print(path, printer, semantics) {
26
- const {indent, print} = printer;
28
+ const {maybe, print} = printer;
27
29
 
28
- indent();
30
+ maybe.indent(!isInsideLabel(path));
29
31
  print('return');
30
32
  maybeSpaceAfterKeyword(path, printer, semantics);
31
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "14.7.2",
3
+ "version": "14.8.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",
@@ -80,7 +80,7 @@
80
80
  "check-dts": "^0.9.0",
81
81
  "escover": "^4.0.1",
82
82
  "eslint": "^9.0.0",
83
- "eslint-plugin-putout": "^26.0.2",
83
+ "eslint-plugin-putout": "^27.0.0",
84
84
  "estree-to-babel": "^11.0.2",
85
85
  "goldstein": "^6.0.1",
86
86
  "just-kebab-case": "^4.2.0",