@putout/printer 18.6.2 → 18.6.4

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,14 @@
1
+ 2026.03.14, v18.6.4
2
+
3
+ feature:
4
+ - ccfe6be @putout/printer: VariableDeclaration: afterIf: simplify
5
+ - 70a6c99 @putout/printer: VariableDeclration: afterIf: simplify
6
+
7
+ 2026.03.14, v18.6.3
8
+
9
+ feature:
10
+ - 5837376 @putout/printer: VariableDeclration: afterIf: simplify
11
+
1
12
  2026.03.13, v18.6.2
2
13
 
3
14
  feature:
@@ -7,6 +7,7 @@ import {isSpaceAfterComma} from './space.js';
7
7
  export const ObjectProperty = (path, printer, semantics) => {
8
8
  const {trailingComma} = semantics;
9
9
  const {shorthand} = path.node;
10
+
10
11
  const {
11
12
  maybe,
12
13
  traverse,
@@ -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,45 @@ 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 notLastPrevVarNotNextVar = createTypeChecker([
27
+ ['-: -> !', callWithPrev(exists)],
28
+ ['-', isTwoLinesDifferenceWithPrev],
29
+ ['-', isLast],
30
+ ['-: -> !', callWithPrev(isVariableDeclaration)],
31
+ ['+: -> !', callWithNext(isVariableDeclaration)],
32
+ ]);
33
+
34
+ const isNoPrevAndNextConst = createTypeChecker([
35
+ ['-: ->', callWithPrev(exists)],
36
+ ['+', callWithNext(isVariableDeclaration)],
37
+ ]);
38
+
39
+ const isNextCoupleLines = createTypeChecker([
40
+ ['-', isNoPrevAndNextConst],
41
+ ['-', isTwoLinesDifferenceWithPrev],
42
+ ['+', callWithNext(isCoupleLines)],
43
+ ]);
44
+
45
+ const noNextParentBlock = createTypeChecker([
46
+ ['-', isNext],
47
+ ['+', isInsideBlock],
48
+ ]);
49
+
23
50
  const notLastCoupleLines = createTypeChecker([
24
51
  ['-', isLast],
25
52
  ['+', isCoupleLines],
@@ -52,28 +79,3 @@ export const afterIf = createTypeChecker([
52
79
  ['+: parentPath -> TSModuleBlock'],
53
80
  ]);
54
81
 
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
- function notLastPrevVarNotNextVar(path) {
69
- const prev = path.getPrevSibling();
70
- const next = path.getNextSibling();
71
-
72
- if (!exists(prev.getPrevSibling()))
73
- return false;
74
-
75
- if (path.node.loc?.start.line === prev.node?.loc?.start.line + 2)
76
- return false;
77
-
78
- return !isLast(path) && prev.isVariableDeclaration() && !next.isVariableDeclaration();
79
- }
@@ -23,6 +23,7 @@ export const report = (coverage) => {
23
23
  for (const index of difference(fullSet(length), covered)) {
24
24
  const currentType = typeNames[index];
25
25
  const rawCode = createRawCode(currentType);
26
+
26
27
  const code = codeFrameColumns(rawCode, {}, {
27
28
  forceColor: true,
28
29
  });
@@ -8,6 +8,7 @@ const noop = () => {};
8
8
  export const TSTypeParameterDeclaration = (path, printer, semantics) => {
9
9
  const {print, indent} = printer;
10
10
  const isNewline = hasComplexParameters(path);
11
+
11
12
  const printSpace = createPrintSpace({
12
13
  isNewline,
13
14
  printer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.6.2",
3
+ "version": "18.6.4",
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",