@putout/printer 11.9.0 → 11.10.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,8 @@
1
+ 2024.12.18, v11.10.0
2
+
3
+ feature:
4
+ - 6c06c0c @putout/printer: ExportDeclaration: no specifiers
5
+
1
6
  2024.12.18, v11.9.0
2
7
 
3
8
  fix:
@@ -89,7 +89,11 @@ module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics)
89
89
  const insideFn = (path.parentPath.isFunction() || path.parentPath.isTSDeclareMethod()) && !path.isTSTypeParameterDeclaration();
90
90
 
91
91
  const propIs = isProperty(path);
92
- const isIndent = isFirst(path) || !looksLikeSwitchCase && !path.isClassMethod() && !insideFn && !propIs;
92
+ const isIndent = isFirst(path)
93
+ || !looksLikeSwitchCase
94
+ && !path.isClassMethod()
95
+ && !insideFn
96
+ && !propIs;
93
97
 
94
98
  for (const {type, value} of leadingComments) {
95
99
  maybe.indent(isIndent);
@@ -35,14 +35,14 @@ module.exports.ExportNamespaceSpecifier = (path, {print}) => {
35
35
  };
36
36
 
37
37
  module.exports.ExportNamedDeclaration = {
38
- print(path, {print, traverse, write, indent, maybe}) {
38
+ print(path, {print, traverse, indent, maybe}) {
39
39
  const {exportKind} = path.node;
40
40
  const specifiers = path.get('specifiers');
41
41
  const {maxOneLineSpecifiers} = options.exports;
42
42
  const source = path.get('source');
43
43
 
44
44
  indent();
45
- write('export');
45
+ print('export');
46
46
 
47
47
  if (exportKind === 'type' && specifiers.length)
48
48
  print(' type');
@@ -61,39 +61,43 @@ module.exports.ExportNamedDeclaration = {
61
61
  const n = specifiers.length;
62
62
  const isNewline = !exists(source) || n > maxOneLineSpecifiers;
63
63
 
64
- if (specifiers.length) {
64
+ if (specifiers && !path.node.declaration) {
65
65
  print.space();
66
- write('{');
67
- indent.inc();
68
- maybe.write.newline(isNewline);
66
+ print('{');
69
67
 
70
- const lastIndex = n - 1;
71
-
72
- for (const [i, spec] of specifiers.entries()) {
73
- const isType = spec.node.exportKind === 'type';
74
- maybe.indent(isNewline);
75
- maybe.write(isType, 'type ');
76
- traverse(spec);
68
+ if (specifiers.length) {
69
+ indent.inc();
70
+ maybe.print.newline(isNewline);
71
+
72
+ const lastIndex = n - 1;
77
73
 
78
- if (i < lastIndex && !isNewline)
79
- write(', ');
74
+ for (const [i, spec] of specifiers.entries()) {
75
+ const isType = spec.node.exportKind === 'type';
76
+ maybe.indent(isNewline);
77
+ maybe.print(isType, 'type ');
78
+ traverse(spec);
79
+
80
+ if (i < lastIndex && !isNewline)
81
+ print(', ');
82
+
83
+ maybe.print(isNewline, ',');
84
+ maybe.print.newline(isNewline);
85
+ }
80
86
 
81
- maybe.write(isNewline, ',');
82
- maybe.write.newline(isNewline);
87
+ indent.dec();
88
+ indent();
83
89
  }
84
90
 
85
- indent.dec();
86
- indent();
87
- write('}');
91
+ print('}');
88
92
  const source = path.get('source');
89
93
 
90
94
  if (exists(source)) {
91
- write(' from ');
95
+ print(' from ');
92
96
  traverse(source);
93
97
  }
94
98
 
95
- write(';');
96
- maybe.write.newline(isNext(path) || isInsideNamespace(path));
99
+ print(';');
100
+ maybe.print.newline(isNext(path) || isInsideNamespace(path));
97
101
 
98
102
  return;
99
103
  }
@@ -115,3 +119,4 @@ module.exports.ExportNamedDeclaration = {
115
119
  markAfter(path);
116
120
  },
117
121
  };
122
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "11.9.0",
3
+ "version": "11.10.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",