@putout/printer 18.7.7 → 18.7.8

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
+ 2026.03.18, v18.7.8
2
+
3
+ feature:
4
+ - 382ab893 @putout/printer: MemberExpression: isLooksLikeChain: simplify
5
+
1
6
  2026.03.17, v18.7.7
2
7
 
3
8
  feature:
@@ -4,7 +4,7 @@ import {
4
4
  isCoupleLines,
5
5
  isNext,
6
6
  } from '#is';
7
- import {isLooksLikeChain} from '../expressions/member-expression/is-looks-like-chain.js';
7
+ import {isLooksLikeChain} from '../expressions/member-expression/is-looks-like-chain/index.js';
8
8
  import {
9
9
  printTrailingComments,
10
10
  hasTrailingCommentsPrinter,
@@ -0,0 +1,19 @@
1
+ import {types} from '@putout/babel';
2
+ import {createTypeChecker} from '#type-checker';
3
+
4
+ const {isCallExpression} = types;
5
+
6
+ export const checkCallsCount = (path, {properties}) => {
7
+ const calls = properties.filter(isCallExpression);
8
+ return checkFilteredCalls(calls);
9
+ };
10
+
11
+ const isTwoCallsWithoutName = createTypeChecker([
12
+ ['-: length -> !', '=', 2],
13
+ ['+: 0.name -> -'],
14
+ ]);
15
+
16
+ const checkFilteredCalls = createTypeChecker([
17
+ ['-', isTwoCallsWithoutName],
18
+ ['+: length', '>', 1],
19
+ ]);
@@ -1,6 +1,7 @@
1
1
  import {types} from '@putout/babel';
2
2
  import {createTypeChecker} from '#type-checker';
3
- import {chain} from './chain.js';
3
+ import {chain} from '../chain.js';
4
+ import {checkCallsCount} from './check-calls-count.js';
4
5
 
5
6
  const hasPropertyWithComment = (properties) => {
6
7
  return properties.find(hasComment);
@@ -37,8 +38,6 @@ const isLastArgInCall = createTypeChecker([
37
38
  ['+', isPathLastArg],
38
39
  ]);
39
40
 
40
- const isCall = (a) => a.type === 'CallExpression';
41
-
42
41
  const callWithRoot = (fn) => (a, {root}) => fn(root);
43
42
  const isExcludedFromChain = createTypeChecker([
44
43
  '+: -> UnaryExpression',
@@ -57,16 +56,6 @@ const isInsideMemberCall = createTypeChecker([
57
56
  const callWithProperties = (fn) => (a, {properties}) => fn(properties);
58
57
  const isFindUpIf = (path) => path.find(isIfUp);
59
58
 
60
- const checkCallsCount = (path, {properties}) => {
61
- const calls = properties.filter(isCall);
62
- const [firstCall] = calls;
63
-
64
- if (calls.length === 2 && !firstCall.name)
65
- return false;
66
-
67
- return calls.length > 1;
68
- };
69
-
70
59
  export const isLooksLikeChain = (path) => {
71
60
  const [root, properties] = chain(path);
72
61
 
@@ -104,3 +93,4 @@ const isIfUp = (path) => {
104
93
 
105
94
  return is;
106
95
  };
96
+
@@ -1,7 +1,7 @@
1
1
  import {maybeParens} from '#maybe-parens';
2
2
  import {createTypeChecker} from '#type-checker';
3
3
  import {maybePrintComputed} from '../object-expression/maybe-print-computed.js';
4
- import {isLooksLikeChain} from './is-looks-like-chain.js';
4
+ import {isLooksLikeChain} from './is-looks-like-chain/index.js';
5
5
 
6
6
  const isObjectInsideArrow = createTypeChecker([
7
7
  '-: node.object -> !ObjectExpression',
@@ -12,7 +12,7 @@ import {
12
12
  hasTrailingComment,
13
13
  } from '#is';
14
14
  import {isInsideTuple} from './is-inside-tuple.js';
15
- import {isLooksLikeChain} from '../member-expression/is-looks-like-chain.js';
15
+ import {isLooksLikeChain} from '../member-expression/is-looks-like-chain/index.js';
16
16
  import {isCommaAfterSpread} from './comma.js';
17
17
  import {isMultilineOption} from '../array-expression/is.js';
18
18
  import {isLinebreakAfterProperty} from './linebreak.js';
@@ -1,6 +1,6 @@
1
1
  import {types} from '@putout/babel';
2
2
  import {createTypeChecker} from '#type-checker';
3
- import {isLooksLikeChain} from '../../expressions/member-expression/is-looks-like-chain.js';
3
+ import {isLooksLikeChain} from '../../expressions/member-expression/is-looks-like-chain/index.js';
4
4
 
5
5
  const {isCallExpression} = types;
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.7.7",
3
+ "version": "18.7.8",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",