@putout/printer 1.81.1 → 1.81.3

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.04, v1.81.3
2
+
3
+ feature:
4
+ - ae2c615 @putout/printer: improve support of SequenceExpressions
5
+
6
+ 2023.05.04, v1.81.2
7
+
8
+ feature:
9
+ - 4033f37 @putout/printer: plugin: add satisfy
10
+
1
11
  2023.05.04, v1.81.1
2
12
 
3
13
  feature:
@@ -1,29 +1,16 @@
1
1
  'use strict';
2
2
 
3
- module.exports.SequenceExpression = {
4
- condition({parentPath}) {
5
- if (parentPath.isArrowFunctionExpression())
6
- return true;
7
-
8
- if (parentPath.isExportDeclaration())
9
- return true;
10
-
11
- return false;
12
- },
13
- before(path, {write}) {
14
- write('(');
15
- },
16
- print(path, {maybe, print}) {
17
- const expressions = path.get('expressions');
18
- const n = expressions.length - 1;
19
-
20
- for (const [index, expression] of expressions.entries()) {
21
- print(expression);
22
- maybe.print(index < n, ',');
23
- maybe.print(index < n, ' ');
24
- }
25
- },
26
- after(path, {write}) {
27
- write(')');
28
- },
3
+ module.exports.SequenceExpression = (path, {maybe, write, traverse}) => {
4
+ const expressions = path.get('expressions');
5
+ const n = expressions.length - 1;
6
+
7
+ write('(');
8
+
9
+ for (const [index, expression] of expressions.entries()) {
10
+ traverse(expression);
11
+ maybe.write(index < n, ',');
12
+ maybe.write(index < n, ' ');
13
+ }
14
+
15
+ write(')');
29
16
  };
@@ -1,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const {isLast} = require('../is');
3
+ const {
4
+ isLast,
5
+ isNext,
6
+ } = require('../is');
4
7
 
5
8
  module.exports.UnaryExpression = unaryExpression;
6
9
  module.exports.UpdateExpression = unaryExpression;
@@ -26,6 +29,7 @@ module.exports.ThrowStatement = (path, {print, indent, maybe}) => {
26
29
 
27
30
  print(';');
28
31
  maybe.print.newline(!isLast(path));
32
+ maybe.print.breakline(isNext(path));
29
33
  };
30
34
 
31
35
  function printUnary(path, name, {print}) {
@@ -3,12 +3,18 @@
3
3
  const {satisfy} = require('../is');
4
4
 
5
5
  module.exports = (plugin) => {
6
- if (!plugin.afterSatisfy && !plugin.beforeSatisfy)
6
+ if (!plugin.afterSatisfy && !plugin.beforeSatisfy && !plugin.satisfy)
7
7
  return plugin;
8
8
 
9
+ const {
10
+ satisfy,
11
+ afterSatisfy = satisfy,
12
+ beforeSatisfy = satisfy,
13
+ } = plugin;
14
+
9
15
  return {
10
- afterIf: createIf(plugin.afterSatisfy),
11
- beforeIf: createIf(plugin.beforeSatisfy),
16
+ afterIf: createIf(afterSatisfy),
17
+ beforeIf: createIf(beforeSatisfy),
12
18
  ...plugin,
13
19
  };
14
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.81.1",
3
+ "version": "1.81.3",
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",