@putout/printer 15.14.0 → 15.15.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.07.29, v15.15.0
2
+
3
+ feature:
4
+ - 79dc3bd @putout/printer: ExportDeclaration: add newline before VariableDeclaration
5
+
6
+ 2025.07.26, v15.14.1
7
+
8
+ feature:
9
+ - ab61623 @putout/printer: EmptyStatement: new line
10
+
1
11
  2025.07.26, v15.14.0
2
12
 
3
13
  feature:
package/lib/printer.d.ts CHANGED
@@ -21,15 +21,14 @@ interface Semantics {
21
21
  type Print = (input: string | types.Node) => void;
22
22
  type Indent = () => void;
23
23
  type Traverse = (input: types.Node) => void;
24
-
25
24
  type MaybeCondition = (condition: boolean) => void;
26
25
 
27
26
  declare const MaybeIndent: {
28
27
  inc: MaybeCondition;
29
28
  dec: MaybeCondition;
30
29
  };
31
- declare function MaybeIndent(condition: boolean): void;
32
30
 
31
+ declare function MaybeIndent(condition: boolean): void;
33
32
  type MaybePrint = (condition: boolean, input: string | types.Node) => void;
34
33
  type MaybeTraverse = (condition: boolean, input: types.Node) => void;
35
34
 
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ const {isLast} = require('#is');
4
+
5
+ module.exports.EmptyStatement = (path, {write, maybe}) => {
6
+ const {parentPath} = path;
7
+ write(';');
8
+ maybe.write.newline(!isLast(path) && !isLast(parentPath));
9
+ };
@@ -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
  };
@@ -22,6 +22,7 @@ const {DoWhileStatement} = require('./do-while-statement/do-while-statement');
22
22
  const {Program} = require('./program/program');
23
23
  const {ContinueStatement} = require('./continue-statement/continue-statement');
24
24
  const {LabeledStatement} = require('./labeled-statement/labeled-statement');
25
+ const {EmptyStatement} = require('./empty-statement/empty-statement');
25
26
 
26
27
  const {
27
28
  ExportNamespaceSpecifier,
@@ -47,9 +48,7 @@ module.exports = {
47
48
  DebuggerStatement,
48
49
  LabeledStatement,
49
50
  Program,
50
- EmptyStatement(path, {write}) {
51
- write(';');
52
- },
51
+ EmptyStatement,
53
52
  InterpreterDirective(path, {print}) {
54
53
  // shebang, hashbang
55
54
  print(`#!${path.node.value}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "15.14.0",
3
+ "version": "15.15.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",