@putout/printer 1.94.0 → 1.96.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.05.11, v1.96.0
2
+
3
+ feature:
4
+ - 9b7297f @putout/printer: improve support of LogicalExpression inside AwaitExpression
5
+
6
+ 2023.05.11, v1.95.0
7
+
8
+ feature:
9
+ - f8e7e47 @putout/printer: improve support of OptionalMemberExpression
10
+
1
11
  2023.05.11, v1.94.0
2
12
 
3
13
  feature:
@@ -1,5 +1,33 @@
1
1
  'use strict';
2
2
 
3
+ const BinaryExpression = {
4
+ condition(path) {
5
+ return path.parentPath.isAwaitExpression();
6
+ },
7
+ before(path, {print}) {
8
+ print('(');
9
+ },
10
+ print(path, {write, traverse, maybe}) {
11
+ const left = path.get('left');
12
+ const right = path.get('right');
13
+ const isLeft = isLogical(path, left);
14
+ const isRight = isLogical(path, right);
15
+
16
+ maybe.write(isLeft, '(');
17
+ traverse(left);
18
+ maybe.write(isLeft, ')');
19
+ write.space();
20
+ write(path.node.operator);
21
+ write.space();
22
+ maybe.write(isRight, '(');
23
+ traverse(right);
24
+ maybe.write(isRight, ')');
25
+ },
26
+ after(path, {print}) {
27
+ print(')');
28
+ },
29
+ };
30
+
3
31
  module.exports.BinaryExpression = BinaryExpression;
4
32
  module.exports.LogicalExpression = BinaryExpression;
5
33
 
@@ -11,20 +39,3 @@ const isLogical = (main, path) => {
11
39
 
12
40
  return main.node.operator !== path.node.operator;
13
41
  };
14
-
15
- function BinaryExpression(path, {write, traverse, maybe}) {
16
- const left = path.get('left');
17
- const right = path.get('right');
18
- const isLeft = isLogical(path, left);
19
- const isRight = isLogical(path, right);
20
-
21
- maybe.write(isLeft, '(');
22
- traverse(left);
23
- maybe.write(isLeft, ')');
24
- write.space();
25
- write(path.node.operator);
26
- write.space();
27
- maybe.write(isRight, '(');
28
- traverse(right);
29
- maybe.write(isRight, ')');
30
- }
@@ -40,10 +40,14 @@ module.exports.MemberExpression = (path, {print, maybe, traverse}) => {
40
40
  maybe.indent.dec(isChain);
41
41
  };
42
42
 
43
- module.exports.OptionalMemberExpression = (path, {print}) => {
44
- const {computed} = path.node;
43
+ module.exports.OptionalMemberExpression = (path, {print, maybe}) => {
44
+ const {
45
+ computed,
46
+ optional,
47
+ } = path.node;
45
48
  print('__object');
46
- print('?.');
49
+ maybe.print(optional, '?');
50
+ print('.');
47
51
 
48
52
  if (computed) {
49
53
  print('[');
@@ -30,10 +30,12 @@ module.exports.ObjectPattern = {
30
30
  const valuePath = property.get('value');
31
31
  const keyPath = property.get('key');
32
32
  const isAssign = valuePath.isAssignmentPattern();
33
+
33
34
  const {
34
35
  shorthand,
35
36
  computed,
36
37
  } = property.node;
38
+
37
39
  const couple = isCoupleLines(valuePath) && !exists(property.getPrevSibling());
38
40
 
39
41
  maybe.indent(is);
@@ -12,6 +12,7 @@ const {
12
12
  TSModuleDeclaration,
13
13
  TSModuleBlock,
14
14
  } = require('./ts-module-declaration');
15
+
15
16
  const {TSInterfaceDeclaration} = require('./ts-interface-declaration');
16
17
 
17
18
  module.exports = {
@@ -8,4 +8,3 @@ module.exports.TSInterfaceDeclaration = (path, {print}) => {
8
8
  print.breakline();
9
9
  print.breakline();
10
10
  };
11
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.94.0",
3
+ "version": "1.96.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",