@putout/printer 8.34.0 → 8.35.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,9 @@
1
+ 2024.05.14, v8.35.0
2
+
3
+ feature:
4
+ - 6eda60b @putout/printer: AssignmentExpression: add new line when takes couple lines
5
+ - 738d2aa @putout/printer: @putout/plugin-promises v15.0.0
6
+
1
7
  2024.05.07, v8.34.0
2
8
 
3
9
  feature:
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  const {isObjectPattern} = require('@putout/babel').types;
4
- const {isParens} = require('./unary-expression/parens');
4
+ const {isParens} = require('../unary-expression/parens');
5
+ const {isCoupleLines} = require('../../is');
5
6
 
6
7
  module.exports.AssignmentExpression = {
7
8
  condition: (path) => {
@@ -18,8 +19,9 @@ module.exports.AssignmentExpression = {
18
19
  before(path, {write}) {
19
20
  write('(');
20
21
  },
21
- print(path, {print}) {
22
+ print(path, {print, maybe}) {
22
23
  const {operator} = path.node;
24
+ maybe.print.breakline(isPrevCoupleLines(path));
23
25
 
24
26
  print('__left');
25
27
  print.space();
@@ -31,3 +33,19 @@ module.exports.AssignmentExpression = {
31
33
  write(')');
32
34
  },
33
35
  };
36
+
37
+ const isPrevCoupleLines = (path) => {
38
+ const {parentPath} = path;
39
+ const prev = parentPath.getPrevSibling();
40
+
41
+ if (!prev.node)
42
+ return false;
43
+
44
+ const currentStart = path.node?.loc.start.line;
45
+ const prevEnd = prev.node?.loc.end.line;
46
+
47
+ if (!isCoupleLines(prev))
48
+ return false;
49
+
50
+ return currentStart - prevEnd < 1;
51
+ };
@@ -27,7 +27,7 @@ const {
27
27
  PrivateName,
28
28
  } = require('./class/class-property');
29
29
 
30
- const {AssignmentExpression} = require('./assignment-expression');
30
+ const {AssignmentExpression} = require('./assignment-expression/assignment-expression');
31
31
  const {ArrayExpression} = require('./array-expression/array-expression');
32
32
  const {ArrayPattern} = require('./array-pattern/array-pattern');
33
33
  const {AssignmentPattern} = require('./assignment-pattern');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "8.34.0",
3
+ "version": "8.35.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",
@@ -48,7 +48,7 @@
48
48
  "@babel/plugin-codemod-object-assign-to-object-spread": "^7.10.4",
49
49
  "@putout/plugin-minify": "^8.0.0",
50
50
  "@putout/plugin-printer": "^3.0.0",
51
- "@putout/plugin-promises": "^14.0.0",
51
+ "@putout/plugin-promises": "^15.0.0",
52
52
  "@putout/plugin-react-hook-form": "^4.0.0",
53
53
  "@putout/plugin-react-hooks": "^6.0.0",
54
54
  "acorn": "^8.8.2",
@@ -56,7 +56,6 @@
56
56
  "check-dts": "^0.7.2",
57
57
  "escover": "^4.0.1",
58
58
  "eslint": "^9.0.0",
59
- "eslint-plugin-n": "^17.0.0",
60
59
  "eslint-plugin-putout": "^22.0.0",
61
60
  "estree-to-babel": "^9.0.0",
62
61
  "just-kebab-case": "^4.2.0",