@putout/printer 1.81.1 → 1.81.2

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,8 @@
1
+ 2023.05.04, v1.81.2
2
+
3
+ feature:
4
+ - 4033f37 @putout/printer: plugin: add satisfy
5
+
1
6
  2023.05.04, v1.81.1
2
7
 
3
8
  feature:
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
+ const insideArrow = ({parentPath}) => parentPath.isArrowFunctionExpression();
4
+ const insideExport = ({parentPath}) => parentPath.isExportDeclaration();
5
+ const insideConst = ({parentPath}) => parentPath.isVariableDeclarator();
6
+
3
7
  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
- },
8
+ satisfy: () => [
9
+ insideArrow,
10
+ insideExport,
11
+ insideConst,
12
+ ],
13
13
  before(path, {write}) {
14
14
  write('(');
15
15
  },
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {isLast} = require('../is');
3
+ const {isLast, isNext} = require('../is');
4
4
 
5
5
  module.exports.UnaryExpression = unaryExpression;
6
6
  module.exports.UpdateExpression = unaryExpression;
@@ -26,6 +26,7 @@ module.exports.ThrowStatement = (path, {print, indent, maybe}) => {
26
26
 
27
27
  print(';');
28
28
  maybe.print.newline(!isLast(path));
29
+ maybe.print.breakline(isNext(path));
29
30
  };
30
31
 
31
32
  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
  };
@@ -17,3 +23,4 @@ const createIf = (getConditions) => {
17
23
  const conditions = getConditions?.() || [];
18
24
  return satisfy(conditions);
19
25
  };
26
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.81.1",
3
+ "version": "1.81.2",
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",