@putout/printer 15.14.1 → 15.16.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.08.01, v15.16.0
2
+
3
+ feature:
4
+ - 3e566b0 @putout/printer: VoidPattern: add
5
+
6
+ 2025.07.29, v15.15.0
7
+
8
+ feature:
9
+ - 79dc3bd @putout/printer: ExportDeclaration: add newline before VariableDeclaration
10
+
1
11
  2025.07.26, v15.14.1
2
12
 
3
13
  feature:
@@ -6,12 +6,14 @@ const {Identifier} = require('./identifier');
6
6
  const {Decorator} = require('../expressions/decorator/decorator');
7
7
  const {StringLiteral} = require('./string-literal');
8
8
  const {DirectiveLiteral} = require('./directive-literal');
9
+ const {VoidPattern} = require('./void-pattern/void-pattern');
9
10
 
10
11
  module.exports = {
11
12
  Identifier,
12
13
  Decorator,
13
14
  DirectiveLiteral,
14
15
  TemplateLiteral,
16
+ VoidPattern,
15
17
  BigIntLiteral(path, {write}) {
16
18
  write(path.node.raw);
17
19
  },
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports.VoidPattern = (path, {write}) => {
4
+ write('void');
5
+ };
@@ -7,4 +7,3 @@ module.exports.EmptyStatement = (path, {write, maybe}) => {
7
7
  write(';');
8
8
  maybe.write.newline(!isLast(path) && !isLast(parentPath));
9
9
  };
10
-
@@ -3,7 +3,11 @@
3
3
  const {types} = require('@putout/babel');
4
4
 
5
5
  const {isParentBlock} = require('#is');
6
- const {markAfter, isMarkedAfter} = require('../../mark');
6
+ const {
7
+ markAfter,
8
+ isMarkedAfter,
9
+ hasPrevNewline,
10
+ } = require('../../mark');
7
11
 
8
12
  const {
9
13
  isNewlineBetweenSiblings,
@@ -12,7 +16,12 @@ const {
12
16
  isLast,
13
17
  } = require('../../is');
14
18
 
15
- const {isExportNamespaceSpecifier} = types;
19
+ const {
20
+ isExportNamespaceSpecifier,
21
+ isVariableDeclaration,
22
+ isExportNamedDeclaration,
23
+ } = types;
24
+
16
25
  const isDeclarationNewline = (path) => isMarkedAfter(path.get('declaration'));
17
26
  const isInsideNamespace = (path) => path.parentPath.isTSModuleBlock();
18
27
 
@@ -39,6 +48,17 @@ module.exports.ExportNamespaceSpecifier = (path, {print}) => {
39
48
  };
40
49
 
41
50
  module.exports.ExportNamedDeclaration = {
51
+ beforeIf(path) {
52
+ const prev = path.getPrevSibling();
53
+
54
+ if (hasPrevNewline(path))
55
+ return false;
56
+
57
+ return isVariableDeclaration(prev);
58
+ },
59
+ before(path, {print}) {
60
+ print.linebreak();
61
+ },
42
62
  print(path, {print, traverse, indent, maybe}, semantics) {
43
63
  const {trailingComma} = semantics;
44
64
  const {exportKind} = path.node;
@@ -125,8 +145,14 @@ module.exports.ExportNamedDeclaration = {
125
145
 
126
146
  return isParentBlock(path);
127
147
  },
128
- after(path, {print}) {
148
+ after(path, {print, indent}) {
149
+ const next = path.getNextSibling();
150
+
151
+ if (isExportNamedDeclaration(next))
152
+ indent();
153
+
129
154
  print.newline();
155
+
130
156
  markAfter(path);
131
157
  },
132
158
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "15.14.1",
3
+ "version": "15.16.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",