@putout/printer 14.7.3 → 15.0.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,18 @@
1
+ 2025.06.01, v15.0.0
2
+
3
+ feature:
4
+ - abb07ed @putout/printer: get rid of Record and Tuple (https://github.com/tc39/proposal-record-tuple/issues/394)
5
+ - 6a5ff0c @putout/printer: @putout/compare v18.0.0
6
+ - 9c147b2 @putout/printer: @putout/plugin-promises v18.0.0
7
+ - 0300161 @putout/printer: @putout/babel v4.0.1
8
+
9
+ 2025.05.26, v14.8.0
10
+
11
+ feature:
12
+ - 1d87093 @putout/printer: eslint-plugin-putout v27.0.0
13
+ - 6b3ea67 @putout/printer: ExportDeclaration: trailingComma
14
+ - fa15bb1 @putout/printer: ObjectExpression: ObjectMethod: trailingComma
15
+
1
16
  2025.05.23, v14.7.3
2
17
 
3
18
  feature:
@@ -39,8 +39,6 @@ const {BinaryExpression} = require('./binary-expression/binary-expression');
39
39
  const {LogicalExpression} = require('./logical-expression/logical-expression');
40
40
  const {ConditionalExpression} = require('./conditional-expression');
41
41
  const {StaticBlock} = require('./class/static-block');
42
- const {RecordExpression} = require('./object-expression/record-expression');
43
- const {TupleExpression} = require('./array-expression/tuple-expression');
44
42
  const {ImportExpression} = require('./import-expression');
45
43
  const {ParenthesizedExpression} = require('./parenthesized-expression/parenthesized-expression');
46
44
 
@@ -77,6 +75,4 @@ module.exports = {
77
75
  ThisExpression(path, {write}) {
78
76
  write('this');
79
77
  },
80
- RecordExpression,
81
- TupleExpression,
82
78
  };
@@ -8,10 +8,10 @@ const maybeSatisfy = require('./satisfy');
8
8
  const {
9
9
  isProgram,
10
10
  isFile,
11
- File,
12
- ExpressionStatement,
13
- Program,
14
11
  isStatement,
12
+ expressionStatement,
13
+ program,
14
+ file,
15
15
  } = types;
16
16
 
17
17
  const isFn = (a) => typeof a === 'function';
@@ -26,13 +26,13 @@ module.exports.maybeThrow = (a, path, b) => {
26
26
  }));
27
27
  };
28
28
 
29
- const maybeStatement = (ast) => isStatement(ast) ? ast : ExpressionStatement(ast);
29
+ const maybeStatement = (ast) => isStatement(ast) ? ast : expressionStatement(ast);
30
30
 
31
- const maybeProgram = (ast) => isProgram(ast) ? ast : Program([
31
+ const maybeProgram = (ast) => isProgram(ast) ? ast : program([
32
32
  maybeStatement(ast),
33
33
  ]);
34
34
 
35
- module.exports.maybeFile = (ast) => isFile(ast) ? ast : File(maybeProgram(ast));
35
+ module.exports.maybeFile = (ast) => isFile(ast) ? ast : file(maybeProgram(ast));
36
36
 
37
37
  module.exports.maybeVisitor = (plugin, path, printer, options) => {
38
38
  if (isFn(plugin))
@@ -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}) {
@@ -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
 
@@ -69,4 +69,3 @@ function isJSXWithComment(path) {
69
69
 
70
70
  return isJSXElement(arg) && leadingComments?.length;
71
71
  }
72
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "14.7.3",
3
+ "version": "15.0.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",
@@ -33,8 +33,8 @@
33
33
  "report": "madrun report"
34
34
  },
35
35
  "dependencies": {
36
- "@putout/babel": "^3.0.0",
37
- "@putout/compare": "^17.0.0",
36
+ "@putout/babel": "^4.0.1",
37
+ "@putout/compare": "^18.0.0",
38
38
  "@putout/operate": "^13.0.0",
39
39
  "@putout/operator-json": "^2.0.0",
40
40
  "fullstore": "^3.0.0",
@@ -72,7 +72,7 @@
72
72
  "@putout/eslint": "^4.1.0",
73
73
  "@putout/plugin-minify": "^10.0.0",
74
74
  "@putout/plugin-printer": "^5.0.0",
75
- "@putout/plugin-promises": "^17.0.0",
75
+ "@putout/plugin-promises": "^18.0.0",
76
76
  "@putout/plugin-react-hook-form": "^6.0.0",
77
77
  "@putout/plugin-react-hooks": "^8.0.1",
78
78
  "acorn": "^8.8.2",
@@ -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",
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- const {ArrayExpression} = require('./array-expression');
4
- const {maybeVisitor} = require('../../maybe');
5
-
6
- module.exports.TupleExpression = (path, operations, semantics) => {
7
- const {write} = operations;
8
- write('#');
9
- maybeVisitor(ArrayExpression, path, operations, semantics);
10
- };
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- const {ObjectExpression} = require('./object-expression');
4
-
5
- module.exports.RecordExpression = (path, operations, semantics) => {
6
- const {write} = operations;
7
- write('#');
8
- ObjectExpression(path, operations, semantics);
9
- };