@putout/printer 1.72.5 → 1.72.7

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.04.26, v1.72.7
2
+
3
+ feature:
4
+ - 7764b71 @putout/printer: improve chaining support of MemberExpression
5
+
6
+ 2023.04.26, v1.72.6
7
+
8
+ feature:
9
+ - 65023d8 @putout/printer: improve support of CallExpression inside of MemberExpression
10
+
1
11
  2023.04.26, v1.72.5
2
12
 
3
13
  feature:
@@ -4,6 +4,7 @@ const {exists} = require('../is');
4
4
 
5
5
  function CallExpression(path, {indent, print, maybe, traverse}) {
6
6
  const isParentCall = toLong(path) && path.parentPath.isCallExpression();
7
+
7
8
  const callee = path.get('callee');
8
9
  const typeParameters = path.get('typeParameters');
9
10
  const isFn = callee.isFunction();
@@ -29,14 +30,14 @@ function CallExpression(path, {indent, print, maybe, traverse}) {
29
30
  for (const [i, arg] of args.entries()) {
30
31
  const isObject = arg.isObjectExpression();
31
32
 
32
- if (isParentCall && !isObject) {
33
+ if (isParentCall && !isObject && n) {
33
34
  print.newline();
34
35
  indent();
35
36
  }
36
37
 
37
38
  print(arg);
38
39
 
39
- if (isParentCall) {
40
+ if (isParentCall && n) {
40
41
  print(',');
41
42
  continue;
42
43
  }
@@ -46,7 +47,7 @@ function CallExpression(path, {indent, print, maybe, traverse}) {
46
47
 
47
48
  if (isParentCall) {
48
49
  indent.dec();
49
- print.breakline();
50
+ maybe.print.breakline(n);
50
51
  }
51
52
 
52
53
  print(')');
@@ -61,9 +61,6 @@ module.exports.OptionalMemberExpression = (path, {print}) => {
61
61
  function isLooksLikeChain(path) {
62
62
  const {parentPath} = path;
63
63
 
64
- if (parentPath.parentPath.isStatement() && !parentPath.parentPath.isExpressionStatement())
65
- return false;
66
-
67
64
  if (path.find(isIfStatement))
68
65
  return false;
69
66
 
@@ -52,9 +52,7 @@ module.exports.isStringAndIdentifier = ([a, b]) => isStringLiteral(a) && isIdent
52
52
  const isIfOrStatement = (a) => isIfStatement(a) || isStatement(a);
53
53
  const isForOfOrStatement = (a) => isForOfStatement(a) || isStatement(a);
54
54
 
55
- module.exports.isIf = (path) => isIfStatement(path.find(
56
- isIfOrStatement,
57
- ));
55
+ module.exports.isIf = (path) => isIfStatement(path.find(isIfOrStatement));
58
56
 
59
57
  module.exports.isForOf = (path) => {
60
58
  const current = path.find(isForOfOrStatement);
@@ -18,7 +18,9 @@ module.exports.JSXElement = {
18
18
  }
19
19
 
20
20
  print('__openingElement');
21
- path.get('children').map(traverse);
21
+ path
22
+ .get('children')
23
+ .map(traverse);
22
24
  print('__closingElement');
23
25
 
24
26
  if (insideFn && insideCall) {
@@ -9,7 +9,9 @@ module.exports.JSXFragment = {
9
9
  },
10
10
  print(path, {print, traverse}) {
11
11
  print('__openingFragment');
12
- path.get('children').map(traverse);
12
+ path
13
+ .get('children')
14
+ .map(traverse);
13
15
  print('__closingFragment');
14
16
  },
15
17
  after(path, {write, indent}) {
@@ -125,6 +125,5 @@ const isNextAssign = (path) => {
125
125
  if (parentPath.isBlockStatement() && parentPath.node.body.length < 3)
126
126
  return false;
127
127
 
128
- return nextPath
129
- .get('expression').isAssignmentExpression();
128
+ return nextPath.get('expression').isAssignmentExpression();
130
129
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.72.5",
3
+ "version": "1.72.7",
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 fro 🐊Putout",