@putout/printer 1.79.0 → 1.79.1

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.02, v1.79.1
2
+
3
+ fix:
4
+ - 1d1af3a @putout/printer: chaining
5
+
1
6
  2023.05.02, v1.79.0
2
7
 
3
8
  feature:
@@ -4,9 +4,12 @@ const {
4
4
  isUnaryExpression,
5
5
  isArrowFunctionExpression,
6
6
  isLogicalExpression,
7
+ isIfStatement,
8
+
7
9
  } = require('@babel/types');
8
10
 
9
11
  const {chain} = require('./chain');
12
+ const {satisfy} = require('../../is');
10
13
 
11
14
  module.exports.MemberExpression = (path, {print, maybe, traverse}) => {
12
15
  const {computed} = path.node;
@@ -56,16 +59,17 @@ module.exports.OptionalMemberExpression = (path, {print}) => {
56
59
 
57
60
  const isCall = (a) => a.type === 'CallExpression';
58
61
 
62
+ const isExcludedFromChain = satisfy([
63
+ isUnaryExpression,
64
+ isArrowFunctionExpression,
65
+ isLogicalExpression,
66
+ isIfStatement,
67
+ ]);
68
+
59
69
  function likeChain(path) {
60
70
  const [root, properties] = chain(path);
61
71
 
62
- if (isUnaryExpression(root))
63
- return false;
64
-
65
- if (isArrowFunctionExpression(root))
66
- return false;
67
-
68
- if (isLogicalExpression(root))
72
+ if (isExcludedFromChain(root))
69
73
  return false;
70
74
 
71
75
  const calls = properties.filter(isCall);
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const {isIdentifier} = require('@babel/types');
4
+
4
5
  const {
5
6
  isForOf,
6
7
  isCoupleLines,
@@ -86,9 +86,7 @@ module.exports.ImportDeclaration = {
86
86
  if (isLast(path))
87
87
  return false;
88
88
 
89
- if (path
90
- .getNextSibling()
91
- .isImportDeclaration())
89
+ if (path.getNextSibling().isImportDeclaration())
92
90
  return false;
93
91
 
94
92
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.79.0",
3
+ "version": "1.79.1",
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",