@putout/printer 9.4.0 → 9.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,14 @@
1
+ 2024.07.11, v9.6.0
2
+
3
+ feature:
4
+ - 0d1f296 @putout/printer: MemberExpression: object used as AssignProperty
5
+
6
+ 2024.06.16, v9.5.0
7
+
8
+ feature:
9
+ - f42012c @putout/printer: c8 v10.1.2
10
+ - b782436 @putout/printer: AssignmentExpression: nested
11
+
1
12
  2024.06.10, v9.4.0
2
13
 
3
14
  feature:
@@ -1,34 +1,38 @@
1
1
  'use strict';
2
2
 
3
- const {isCoupleLines} = require('../../is');
4
- const {isMarkedAfter} = require('../../mark');
5
3
  const {
6
4
  maybePrintLeftBrace,
7
5
  maybePrintRightBrace,
8
6
  } = require('./maybe-write-brace');
9
7
 
8
+ const {
9
+ isExpressionStatement,
10
+ isAssignmentExpression,
11
+ } = require('@putout/babel').types;
12
+
10
13
  module.exports.AssignmentExpression = (path, printer, semantics) => {
11
- const {print, maybe} = printer;
14
+ const {print} = printer;
12
15
  const {operator} = path.node;
13
16
 
14
- maybe.print.breakline(isPrevCoupleLines(path));
15
17
  maybePrintLeftBrace(path, printer, semantics);
16
18
  print('__left');
17
19
  print.space();
18
20
  print(operator);
19
- print.space();
21
+
22
+ if (isMultiline(path))
23
+ print.breakline();
24
+ else
25
+ print.space();
26
+
20
27
  print('__right');
21
28
  maybePrintRightBrace(path, printer, semantics);
22
29
  };
23
30
 
24
- const isPrevCoupleLines = ({parentPath}) => {
25
- const prev = parentPath.getPrevSibling();
26
-
27
- if (isMarkedAfter(prev))
28
- return false;
31
+ function isMultiline(path) {
32
+ const {right} = path.node;
29
33
 
30
- if (!prev.node)
34
+ if (!path.parentPath.find(isExpressionStatement))
31
35
  return false;
32
36
 
33
- return isCoupleLines(prev);
34
- };
37
+ return isAssignmentExpression(right);
38
+ }
@@ -12,13 +12,13 @@ const {satisfy} = require('../../is');
12
12
  const isArgOfCall = (path) => path.parentPath.isCallExpression() && path.parentPath.get('arguments.0') === path;
13
13
 
14
14
  module.exports.MemberExpression = (path, {print, maybe, traverse}) => {
15
- const {computed} = path.node;
16
15
  const object = path.get('object');
17
- const isObjectAwait = object.isAwaitExpression();
16
+ const isParens = object.isAwaitExpression() || object.isAssignmentExpression();
17
+ const {computed} = path.node;
18
18
 
19
- maybe.print(isObjectAwait, '(');
19
+ maybe.print(isParens, '(');
20
20
  traverse(object);
21
- maybe.print(isObjectAwait, ')');
21
+ maybe.print(isParens, ')');
22
22
 
23
23
  if (computed) {
24
24
  print('[');
@@ -109,3 +109,4 @@ function likeChain(path) {
109
109
 
110
110
  return calls.length > 1;
111
111
  }
112
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "9.4.0",
3
+ "version": "9.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",
@@ -51,13 +51,13 @@
51
51
  "@putout/plugin-react-hook-form": "^4.0.0",
52
52
  "@putout/plugin-react-hooks": "^6.0.0",
53
53
  "acorn": "^8.8.2",
54
- "c8": "^9.1.0",
55
- "goldstein": "^5.14.0",
54
+ "c8": "^10.1.2",
56
55
  "check-dts": "^0.8.0",
57
56
  "escover": "^4.0.1",
58
57
  "eslint": "^9.0.0",
59
58
  "eslint-plugin-putout": "^22.0.0",
60
59
  "estree-to-babel": "^9.0.0",
60
+ "goldstein": "^5.14.0",
61
61
  "just-kebab-case": "^4.2.0",
62
62
  "madrun": "^10.0.0",
63
63
  "mock-require": "^3.0.3",