@putout/printer 18.2.4 → 18.2.5

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.07, v18.2.5
2
+
3
+ fix:
4
+ - 3514e0f @putout/printer: type-checker: check for undefined
5
+
1
6
  2026.03.07, v18.2.4
2
7
 
3
8
  fix:
@@ -13,7 +13,7 @@ import {
13
13
  isInsideArray,
14
14
  } from '#is';
15
15
 
16
- const isZero = (path) => !path.node.elements.length;
16
+ const isZero = (length) => !length;
17
17
 
18
18
  const isParentProperty = (path) => path.find(isObjectProperty);
19
19
 
@@ -203,7 +203,7 @@ const isBodyWithOneElement = createTypeChecker([
203
203
  ]);
204
204
 
205
205
  export const isMultiLine = createTypeChecker([
206
- ['-', isZero],
206
+ ['-: node.elements.length', isZero],
207
207
  ['+', isBodyWithOneElement],
208
208
  ['+', isMoreThenMaxElementLengthInOneLine],
209
209
  ['+', isElementsMoreThenMaxWithFirstString],
@@ -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.5",
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",