@putout/printer 18.2.4 → 18.2.6

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,14 @@
1
+ 2026.03.08, v18.2.6
2
+
3
+ feature:
4
+ - 9363494 @putout/printer: ArrayExpression: isObjectAfterSimple: type-check
5
+ - 463944a @putout/printer: ArrayExpression: isZero -> !Boolean
6
+
7
+ 2026.03.07, v18.2.5
8
+
9
+ fix:
10
+ - 3514e0f @putout/printer: type-checker: check for undefined
11
+
1
12
  2026.03.07, v18.2.4
2
13
 
3
14
  fix:
@@ -1,4 +1,5 @@
1
- import {isNextObject, isPrevObject} from '#is';
1
+ import {isNextObject} from '#is';
2
+ import {createTypeChecker} from '#type-checker';
2
3
 
3
4
  const SIMPLE_TYPES = [
4
5
  'ArrayExpression',
@@ -9,11 +10,9 @@ const SIMPLE_TYPES = [
9
10
  'NewExpression',
10
11
  ];
11
12
 
12
- export const isObjectAfterSimple = (a) => {
13
- const {type} = a;
14
-
15
- if (!isNextObject(a) || isPrevObject(a))
16
- return false;
17
-
18
- return SIMPLE_TYPES.includes(type);
19
- };
13
+ const isSimpleType = ({type}) => SIMPLE_TYPES.includes(type);
14
+
15
+ export const isObjectAfterSimple = createTypeChecker([
16
+ ['-: -> !', isNextObject],
17
+ ['+', isSimpleType],
18
+ ]);
@@ -13,8 +13,6 @@ import {
13
13
  isInsideArray,
14
14
  } from '#is';
15
15
 
16
- const isZero = (path) => !path.node.elements.length;
17
-
18
16
  const isParentProperty = (path) => path.find(isObjectProperty);
19
17
 
20
18
  const isNumbersArray = createTypeChecker([
@@ -203,7 +201,7 @@ const isBodyWithOneElement = createTypeChecker([
203
201
  ]);
204
202
 
205
203
  export const isMultiLine = createTypeChecker([
206
- ['-', isZero],
204
+ ['-: node.elements.length -> !', Boolean],
207
205
  ['+', isBodyWithOneElement],
208
206
  ['+', isMoreThenMaxElementLengthInOneLine],
209
207
  ['+', isElementsMoreThenMaxWithFirstString],
@@ -65,10 +65,6 @@ export const isNextObject = (a) => a
65
65
  .getNextSibling()
66
66
  .isObjectExpression();
67
67
 
68
- export const isPrevObject = (a) => a
69
- .getPrevSibling()
70
- .isObjectExpression();
71
-
72
68
  export const isFirst = (path) => path.node === path.parentPath.node.body?.[0];
73
69
  export const isPrevBody = (path) => path
74
70
  .getPrevSibling()
@@ -77,5 +77,5 @@ function createRawCode(currentType) {
77
77
  }
78
78
 
79
79
  return operator;
80
- }/* c8 ignore end */
80
+ } /* c8 ignore end */
81
81
 
@@ -3,6 +3,8 @@ import {instrument as _instrument} from '#type-checker/instrument';
3
3
  import {parseOperation, parseTypeNames} from './parsers.js';
4
4
  import {equal, maybeCall} from './comparators.js';
5
5
 
6
+ const isUndefined = (a) => typeof a === 'undefined';
7
+
6
8
  const SKIP = [
7
9
  Infinity,
8
10
  false,
@@ -22,12 +24,10 @@ export const createTypeChecker = (typeNames, overrides = {}) => {
22
24
  if (selector)
23
25
  currentPath = jessy(selector, path);
24
26
 
25
- if (!currentPath)
27
+ if (isUndefined(currentPath))
26
28
  return SKIP;
27
29
 
28
- const {type} = currentPath;
29
-
30
- if (equal(not, type, typeName))
30
+ if (currentPath && equal(not, currentPath.type, typeName))
31
31
  return [index, result];
32
32
 
33
33
  if (maybeCall(typeName, not, currentPath, options))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.2.4",
3
+ "version": "18.2.6",
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",