@putout/printer 2.4.0 → 2.6.0

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,13 @@
1
+ 2023.06.13, v2.6.0
2
+
3
+ fix:
4
+ - 30e2aa1 @putout/printer: ObjectExpression: used as argument call
5
+
6
+ 2023.06.12, v2.5.0
7
+
8
+ feature:
9
+ - 1810515 @putout/printer: WhileStatement: maybe
10
+
1
11
  2023.06.12, v2.4.0
2
12
 
3
13
  feature:
@@ -12,6 +12,7 @@ const {
12
12
  } = require('../../is');
13
13
 
14
14
  const {parseComments} = require('../../comments');
15
+ const {isObjectExpression} = require('@babel/types');
15
16
 
16
17
  const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
17
18
  const isLogical = (path) => path.get('argument').isLogicalExpression();
@@ -28,9 +29,7 @@ module.exports.ObjectExpression = (path, {print, maybe, indent, write}, semantic
28
29
 
29
30
  maybe.print(parens, '(');
30
31
  print('{');
31
- parseComments(path, {
32
- write,
33
- }, semantics);
32
+ parseComments(path, {write}, semantics);
34
33
  maybe.print.newline(manyLines);
35
34
 
36
35
  for (const property of properties) {
@@ -85,6 +84,13 @@ const notLastArgInsideCall = (path) => {
85
84
  if (!parentPath.isCallExpression())
86
85
  return false;
87
86
 
87
+ const {properties} = path.node;
88
+
89
+ for (const property of properties) {
90
+ if (isObjectExpression(property.value))
91
+ return false;
92
+ }
93
+
88
94
  return path !== parentPath
89
95
  .get('arguments')
90
96
  .at(-1);
@@ -35,9 +35,7 @@ module.exports.BlockStatement = {
35
35
  print(element);
36
36
  }
37
37
 
38
- parseComments(path, {
39
- write,
40
- }, semantics);
38
+ parseComments(path, {write}, semantics);
41
39
 
42
40
  indent.dec();
43
41
  maybe.indent(body.length);
@@ -61,11 +61,7 @@ module.exports.VariableDeclaration = {
61
61
  continue;
62
62
  }
63
63
 
64
- parseLeadingComments(next, {
65
- print,
66
- maybe,
67
- indent,
68
- }, semantics);
64
+ parseLeadingComments(next, {print, maybe, indent}, semantics);
69
65
  }
70
66
  }
71
67
 
@@ -1,30 +1,32 @@
1
1
  'use strict';
2
2
 
3
3
  const {isLast} = require('../is');
4
+ const {markAfter} = require('../mark');
4
5
 
5
- module.exports.WhileStatement = (path, {print, indent}) => {
6
- print('while (');
7
- print('__test');
8
- print(')');
9
-
10
- if (path.node.body.body) {
11
- print(' ');
12
- print('__body');
13
- } else {
14
- indent.inc();
15
- print.newline();
16
- print('__body');
17
- indent.dec();
18
- }
19
-
20
- if (shouldAddNewlineAfter(path)) {
6
+ module.exports.WhileStatement = {
7
+ print(path, {print, indent}) {
8
+ print('while (');
9
+ print('__test');
10
+ print(')');
11
+
12
+ if (path.node.body.body) {
13
+ print(' ');
14
+ print('__body');
15
+ } else {
16
+ indent.inc();
17
+ print.newline();
18
+ print('__body');
19
+ indent.dec();
20
+ }
21
+ },
22
+ afterIf(path) {
23
+ if (isLast(path))
24
+ return false;
25
+
26
+ return true;
27
+ },
28
+ after(path, {print}) {
21
29
  print.linebreak();
22
- }
30
+ markAfter(path);
31
+ },
23
32
  };
24
-
25
- function shouldAddNewlineAfter(path) {
26
- if (isLast(path))
27
- return false;
28
-
29
- return true;
30
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",