@putout/printer 18.24.0 → 18.25.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,10 @@
1
+ 2026.06.27, v18.25.0
2
+
3
+ feature:
4
+ - 5478906e @putout/printer: ExportDefaultDeclaration: needsSemicolon: simplify
5
+ - 918525a4 @putout/printer: ExportDeclaration: isNewlineAfter: simplify
6
+ - 9e1ea558 @putout/printer: ExportDefaultDeclaration: inside BlockStatement
7
+
1
8
  2026.06.27, v18.24.0
2
9
 
3
10
  feature:
@@ -1,41 +1,46 @@
1
1
  import {types} from '@putout/babel';
2
- import {isNext} from '#is';
2
+ import {
3
+ isNext,
4
+ callWithParent,
5
+ callWithNext,
6
+ } from '#is';
7
+ import {createTypeChecker} from '#type-checker';
3
8
 
4
9
  const {
5
10
  isVariableDeclaration,
6
11
  isFunction,
12
+ isBlockStatement,
7
13
  } = types;
8
14
 
9
- function shouldAddSemicolon(path) {
10
- if (path.isClassDeclaration())
11
- return false;
12
-
13
- return !path.isFunctionDeclaration();
14
- }
15
+ const needsSemicolon = createTypeChecker([
16
+ '-: -> ClassDeclaration',
17
+ '+: -> !FunctionDeclaration',
18
+ ]);
19
+
20
+ const afterIf = createTypeChecker([
21
+ callWithParent(isBlockStatement),
22
+ isNext,
23
+ ]);
15
24
 
16
25
  export const ExportDefaultDeclaration = {
17
26
  print(path, {print, traverse, maybe}) {
18
27
  const declaration = path.get('declaration');
28
+ print.indent();
19
29
  print('export default ');
20
30
  traverse(declaration);
21
- maybe.print(shouldAddSemicolon(declaration), ';');
31
+ maybe.print(needsSemicolon(declaration), ';');
22
32
  },
23
- afterSatisfy: () => [
24
- isNext,
25
- ],
26
- after(path, {print, maybe}) {
33
+ afterIf,
34
+ after(path, {print}) {
27
35
  print.newline();
28
- maybe.print.newline(!isVarAfterFn(path));
36
+
37
+ if (isNewlineAfter(path))
38
+ print.newline();
29
39
  },
30
40
  };
31
41
 
32
- function isVarAfterFn(path) {
33
- const next = path.getNextSibling();
34
-
35
- if (!isVariableDeclaration(next))
36
- return false;
37
-
38
- const {declaration} = path.node;
39
-
40
- return isFunction(declaration);
41
- }
42
+ const isNewlineAfter = createTypeChecker([
43
+ ['-: parentPath -> BlockStatement'],
44
+ ['+: -> !', callWithNext(isVariableDeclaration)],
45
+ ['+: node.declaration -> !', isFunction],
46
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.24.0",
3
+ "version": "18.25.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",