@putout/printer 18.3.3 → 18.3.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,8 @@
1
+ 2026.03.10, v18.3.4
2
+
3
+ feature:
4
+ - d3410bd @putout/printer: BlockStatement: simplify
5
+
1
6
  2026.03.09, v18.3.3
2
7
 
3
8
  feature:
@@ -1,5 +1,9 @@
1
- import {isNewlineBetweenSiblings} from '#is';
1
+ import {
2
+ isNewlineBetweenSiblings,
3
+ isNext,
4
+ } from '#is';
2
5
  import {printParams} from '#print-params';
6
+ import {markAfter} from '#mark';
3
7
  import {printKey} from '../object-expression/print-key.js';
4
8
  import {printKind} from './kind.js';
5
9
 
@@ -11,6 +15,7 @@ export const ObjectMethod = {
11
15
  write('async ');
12
16
  },
13
17
  print(path, printer, semantics) {
18
+ const {trailingComma} = semantics;
14
19
  const {print} = printer;
15
20
 
16
21
  printKind(path, printer);
@@ -19,6 +24,12 @@ export const ObjectMethod = {
19
24
 
20
25
  print.space();
21
26
  print('__body');
27
+
28
+ if (isNext(path) || trailingComma)
29
+ print(',');
30
+
31
+ print.newline();
32
+ markAfter(path);
22
33
  },
23
34
  afterIf(path) {
24
35
  return isNewlineBetweenSiblings(path);
@@ -68,6 +68,7 @@ export const shouldAddNewlineAfter = createTypeChecker([
68
68
  ['-', isLooksLikeInsideFn],
69
69
  ['-', isLast],
70
70
  ['-', isExportFunction],
71
+ ['-: parentPath -> ObjectMethod'],
71
72
  ['+: -> !', isNextIfAlternate],
72
73
  ]);
73
74
 
@@ -1,15 +1,11 @@
1
1
  import {types} from '@putout/babel';
2
2
  import {markAfter} from '#mark';
3
- import {isNext} from '#is';
4
3
  import {parseComments} from '../../comment/comment.js';
5
4
  import {getDirectives} from './get-directives.js';
6
5
  import {isCallInsideChain} from './is-call-inside-chain.js';
7
6
  import {shouldAddNewlineAfter} from './block-statement-newline.js';
8
7
 
9
- const {
10
- isObjectMethod,
11
- isArrayExpression,
12
- } = types;
8
+ const {isArrayExpression} = types;
13
9
 
14
10
  const isFirstStatement = (path) => path.node.body[0];
15
11
  const isFirstDirective = (path) => path.node.directives?.[0];
@@ -27,7 +23,6 @@ const isInsideArrayTupleOfThree = (path) => {
27
23
 
28
24
  export const BlockStatement = {
29
25
  print(path, printer, semantics) {
30
- const {trailingComma} = semantics;
31
26
  const {
32
27
  indent,
33
28
  maybe,
@@ -70,11 +65,6 @@ export const BlockStatement = {
70
65
  write('}');
71
66
 
72
67
  maybe.indent.dec(callInsideChain);
73
-
74
- const {parentPath} = path;
75
-
76
- if (isObjectMethod(parentPath))
77
- maybe.write(isNext(parentPath) || trailingComma, ',');
78
68
  },
79
69
  afterIf: shouldAddNewlineAfter,
80
70
  after(path, {write}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.3.3",
3
+ "version": "18.3.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",