@putout/printer 18.0.12 → 18.0.13

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
+ 2026.03.05, v18.0.13
2
+
3
+ feature:
4
+ - 5a991b6 @putout/printer: FunctionDeclaration: simplify
5
+
1
6
  2026.03.05, v18.0.12
2
7
 
3
8
  fix:
@@ -5,7 +5,6 @@ import {isNext, isNextParent} from '#is';
5
5
  import {createTypeChecker} from '#type-checker';
6
6
 
7
7
  const {
8
- isAssignmentExpression,
9
8
  isExportNamedDeclaration,
10
9
  isExpressionStatement,
11
10
  isFunctionDeclaration,
@@ -13,9 +12,17 @@ const {
13
12
 
14
13
  const hasFnBody = ({node}) => node.body.body.length;
15
14
 
16
- const isInsideExportDefaultWithBody = createTypeChecker([
17
- '-: parentPath -> !ExportDefaultDeclaration',
18
- ['+', hasFnBody],
15
+ const getNext = (fn) => (path) => fn(path.getNextSibling());
16
+
17
+ const isIndentAfter = createTypeChecker([
18
+ ['+', getNext(isFunctionDeclaration)],
19
+ ['+', isNext],
20
+ ['-: -> !', getNext(isExpressionStatement)],
21
+ ]);
22
+
23
+ const isNotInsideExportDefaultWithBody = createTypeChecker([
24
+ '+: parentPath -> !ExportDefaultDeclaration',
25
+ ['+: -> !', hasFnBody],
19
26
  ]);
20
27
 
21
28
  const isInsideBlockLike = createTypeChecker([
@@ -24,9 +31,6 @@ const isInsideBlockLike = createTypeChecker([
24
31
  ['+: -> !', hasFnBody],
25
32
  ]);
26
33
 
27
- const not = (fn) => (...a) => !fn(...a);
28
- const notInsideExportDefaultWithBody = not(isInsideExportDefaultWithBody);
29
-
30
34
  const isInsideNamedExport = ({parentPath}) => isExportNamedDeclaration(parentPath);
31
35
 
32
36
  export const FunctionDeclaration = {
@@ -64,24 +68,10 @@ export const FunctionDeclaration = {
64
68
  },
65
69
  afterSatisfy: () => [isNext, isNextParent, isInsideBlockLike],
66
70
  after(path, {indent, maybe}) {
67
- if (isNextAssign(path) || isNextFunction(path) || isNext(path))
71
+ if (isIndentAfter(path))
68
72
  indent();
69
73
 
70
- maybe.write.newline(notInsideExportDefaultWithBody(path));
74
+ maybe.write.newline(isNotInsideExportDefaultWithBody(path));
71
75
  markAfter(path);
72
76
  },
73
77
  };
74
-
75
- const isNextFunction = (path) => {
76
- const next = path.getNextSibling();
77
- return isFunctionDeclaration(next);
78
- };
79
-
80
- const isNextAssign = (path) => {
81
- const next = path.getNextSibling();
82
-
83
- if (!isExpressionStatement(next))
84
- return false;
85
-
86
- return isAssignmentExpression(next.node.expression);
87
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.0.12",
3
+ "version": "18.0.13",
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",