@putout/printer 2.17.0 → 2.19.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.16, v2.19.0
2
+
3
+ feature:
4
+ - 8b5f8c4 @putout/printer: BinaryExpression: minification of UnaryExpression (coderaiser/minify#105)
5
+
6
+ 2023.06.15, v2.18.0
7
+
8
+ feature:
9
+ - ad883dc @putout/printer: VariableDeclaration: no newline when previous has
10
+
1
11
  2023.06.15, v2.17.0
2
12
 
3
13
  feature:
@@ -4,6 +4,7 @@ const {
4
4
  concatanate,
5
5
  isConcatenation,
6
6
  } = require('./concatanate');
7
+ const {maybeSpace} = require('./maybe-space');
7
8
 
8
9
  const BinaryExpression = {
9
10
  condition(path) {
@@ -38,7 +39,7 @@ const BinaryExpression = {
38
39
  print('__left');
39
40
  print.space();
40
41
  print(path.node.operator);
41
- print.space();
42
+ maybeSpace(path, {print});
42
43
  print('__right');
43
44
  },
44
45
  after(path, {print}) {
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ module.exports.maybeSpace = (path, {print}) => {
4
+ const {right} = path.node;
5
+
6
+ if (right.type === 'UnaryExpression' && right.operator === '+')
7
+ return print(' ');
8
+
9
+ return print.space();
10
+ };
11
+
@@ -128,6 +128,10 @@ function notLastPrevVarNotNextVar(path) {
128
128
 
129
129
  function isNextCoupleLines(path) {
130
130
  const next = path.getNextSibling();
131
+ const prev = path.getPrevSibling();
132
+
133
+ if (path.node.loc?.start.line === prev.node?.loc?.start.line + 2)
134
+ return false;
131
135
 
132
136
  return isCoupleLines(next);
133
137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.17.0",
3
+ "version": "2.19.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",