@putout/printer 18.8.1 → 18.8.2

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,9 @@
1
+ 2026.03.19, v18.8.2
2
+
3
+ feature:
4
+ - 62e8f395 @putout/printer: ObjectPattern: isIndentAfterNewline
5
+ - 03b337f7 @putout/printer: ObjectPattern: isNewlineAfterComma: simplify
6
+
1
7
  2026.03.19, v18.8.1
2
8
 
3
9
  feature:
@@ -59,7 +59,8 @@ export const printLeadingComments = (path, printer, semantics, {currentTraverse}
59
59
  export const printTrailingComments = (path, printer, semantics, {currentTraverse}) => {
60
60
  const {print} = printer;
61
61
  const {
62
- trailingComments = []} = path.node;
62
+ trailingComments = [],
63
+ } = path.node;
63
64
 
64
65
  const {
65
66
  printTrailingCommentLine,
@@ -39,9 +39,10 @@ export const isCommaAfterProperty = createTypeChecker([
39
39
  ]);
40
40
 
41
41
  export const isNewlineAfterComma = createTypeChecker([
42
+ ['+', hasOptionIs],
43
+ ['+', isPrevAssignObject],
42
44
  ['+', isCoupleOption],
45
+ ['+', isNextAssignObject],
43
46
  ['-: key -> -'],
44
- ['-', isPrevAssign],
45
- ['-: parentPath', isInsideForOf],
46
47
  ['+: node.value.right -> ObjectExpression'],
47
48
  ]);
@@ -2,6 +2,7 @@ import {createTypeChecker} from '#type-checker';
2
2
  import {
3
3
  hasOptionIs,
4
4
  isInsideFn,
5
+ isNextAssignObject,
5
6
  isPrevAssignObject,
6
7
  } from './is.js';
7
8
 
@@ -10,3 +11,8 @@ export const isIndentBeforeProperty = createTypeChecker([
10
11
  ['+', isPrevAssignObject],
11
12
  ['+', hasOptionIs],
12
13
  ]);
14
+
15
+ export const isIndentAfterNewline = createTypeChecker([
16
+ ['-: node.value -> AssignmentPattern'],
17
+ ['+', isNextAssignObject],
18
+ ]);
@@ -12,13 +12,14 @@ import {
12
12
  isCommaAfterProperty,
13
13
  isNewlineAfterComma,
14
14
  } from './comma.js';
15
- import {isIndentBeforeProperty} from './indent.js';
15
+ import {
16
+ isIndentBeforeProperty,
17
+ isIndentAfterNewline,
18
+ } from './indent.js';
16
19
  import {
17
20
  isCoupleProperties,
18
21
  isIndent,
19
22
  isInsideFn,
20
- isNextAssignObject,
21
- isPrevAssignObject,
22
23
  } from './is.js';
23
24
 
24
25
  export const ObjectPattern = {
@@ -52,8 +53,6 @@ export const ObjectPattern = {
52
53
  maybe.print.newline(is && notInsideFn);
53
54
 
54
55
  for (const [i, property] of properties.entries()) {
55
- const prevAssignObject = i && isPrevAssignObject(property);
56
-
57
56
  if (isIndentBeforeProperty(property, {is}))
58
57
  indent();
59
58
 
@@ -65,8 +64,6 @@ export const ObjectPattern = {
65
64
  continue;
66
65
  }
67
66
 
68
- const nextAssignObject = isNextAssignObject(property);
69
-
70
67
  const valuePath = property.get('value');
71
68
  const keyPath = property.get('key');
72
69
  const isAssign = valuePath.isAssignmentPattern();
@@ -97,22 +94,16 @@ export const ObjectPattern = {
97
94
  if (isCommaAfterProperty(property, {is, couple}))
98
95
  print(',');
99
96
 
100
- if (isNewlineAfterComma(property, {couple})) {
101
- print.newline();
102
- continue;
103
- }
104
-
105
- if (!isAssign && nextAssignObject && notInsideFn) {
106
- print.breakline();
107
- continue;
108
- }
109
-
110
- if (is || hasObject || prevAssignObject && notInsideFn) {
97
+ if (isNewlineAfterComma(property, {is, couple})) {
111
98
  print.newline();
99
+
100
+ if (isIndentAfterNewline(property))
101
+ indent();
102
+
112
103
  continue;
113
104
  }
114
105
 
115
- if (i < n && !(isAssign && couple))
106
+ if (i < n)
116
107
  print.space();
117
108
  }
118
109
 
@@ -42,7 +42,12 @@ export const report = (coverage) => {
42
42
  };
43
43
 
44
44
  const setLine = (name, index) => {
45
- const [at, uri, line, column] = name.split(':');
45
+ const [
46
+ at,
47
+ uri,
48
+ line,
49
+ column,
50
+ ] = name.split(':');
46
51
  const newLine = Number(line) + index + 1;
47
52
 
48
53
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.8.1",
3
+ "version": "18.8.2",
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",