@putout/printer 18.6.2 → 18.6.3

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.14, v18.6.3
2
+
3
+ feature:
4
+ - 5837376 @putout/printer: VariableDeclration: afterIf:
5
+
1
6
  2026.03.13, v18.6.2
2
7
 
3
8
  feature:
@@ -33,7 +33,7 @@ const isPathIsConsequent = ({node, parentPath}) => node !== parentPath.node.cons
33
33
 
34
34
  const isBeforeElse = createTypeChecker([
35
35
  ['-: parentPath -> !IfStatement'],
36
- ['-:', isPathIsConsequent],
36
+ ['-', isPathIsConsequent],
37
37
  ['+: parentPath.node.alternate', Boolean],
38
38
  ]);
39
39
 
@@ -8,18 +8,37 @@ import {
8
8
  isLast,
9
9
  isNewlineBetweenSiblings,
10
10
  isNext,
11
+ callWithPrev,
11
12
  } from '#is';
12
13
 
13
- const noNextParentBlock = createTypeChecker([
14
- ['-', isNext],
15
- ['+', isInsideBlock],
16
- ]);
14
+ const isTwoLinesDifferenceWithPrev = (path) => {
15
+ const prev = path.getPrevSibling();
16
+
17
+ return path.node.loc?.start.line === prev.node?.loc?.start?.line + 2;
18
+ };
17
19
 
18
20
  const {
19
21
  isIfStatement,
20
22
  isFunctionDeclaration,
23
+ isVariableDeclaration,
21
24
  } = types;
22
25
 
26
+ const isNoPrevAndNextConst = createTypeChecker([
27
+ ['-: ->', callWithPrev(exists)],
28
+ ['+', callWithNext(isVariableDeclaration)],
29
+ ]);
30
+
31
+ const isNextCoupleLines = createTypeChecker([
32
+ ['-', isNoPrevAndNextConst],
33
+ ['-', isTwoLinesDifferenceWithPrev],
34
+ ['+', callWithNext(isCoupleLines)],
35
+ ]);
36
+
37
+ const noNextParentBlock = createTypeChecker([
38
+ ['-', isNext],
39
+ ['+', isInsideBlock],
40
+ ]);
41
+
23
42
  const notLastCoupleLines = createTypeChecker([
24
43
  ['-', isLast],
25
44
  ['+', isCoupleLines],
@@ -52,19 +71,6 @@ export const afterIf = createTypeChecker([
52
71
  ['+: parentPath -> TSModuleBlock'],
53
72
  ]);
54
73
 
55
- function isNextCoupleLines(path) {
56
- const next = path.getNextSibling();
57
- const prev = path.getPrevSibling();
58
-
59
- if (!exists(prev.getPrevSibling()) && next.isVariableDeclaration())
60
- return false;
61
-
62
- if (path.node.loc?.start.line === prev.node?.loc?.start?.line + 2)
63
- return false;
64
-
65
- return isCoupleLines(next);
66
- }
67
-
68
74
  function notLastPrevVarNotNextVar(path) {
69
75
  const prev = path.getPrevSibling();
70
76
  const next = path.getNextSibling();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.6.2",
3
+ "version": "18.6.3",
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",