@putout/printer 18.2.2 → 18.2.4

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,16 @@
1
+ 2026.03.07, v18.2.4
2
+
3
+ fix:
4
+ - 61b7dec @putout/printer: ArrayExpression: array-inside-call: filesystem
5
+
6
+ 2026.03.07, v18.2.3
7
+
8
+ fix:
9
+ - 355176d @putout/printer: instrument -> instrumentName
10
+
11
+ feature:
12
+ - 85a60d6 @putout/printer: type-checker: report
13
+
1
14
  2026.03.07, v18.2.2
2
15
 
3
16
  feature:
@@ -186,4 +186,3 @@ const isSimpleAfterObject = createTypeChecker([
186
186
  ['-', callWithNext(isObjectExpression)],
187
187
  ['+', callWithPrev(isObjectExpression)],
188
188
  ]);
189
-
@@ -13,6 +13,8 @@ import {
13
13
  isInsideArray,
14
14
  } from '#is';
15
15
 
16
+ const isZero = (path) => !path.node.elements.length;
17
+
16
18
  const isParentProperty = (path) => path.find(isObjectProperty);
17
19
 
18
20
  const isNumbersArray = createTypeChecker([
@@ -201,6 +203,7 @@ const isBodyWithOneElement = createTypeChecker([
201
203
  ]);
202
204
 
203
205
  export const isMultiLine = createTypeChecker([
206
+ ['-', isZero],
204
207
  ['+', isBodyWithOneElement],
205
208
  ['+', isMoreThenMaxElementLengthInOneLine],
206
209
  ['+', isElementsMoreThenMaxWithFirstString],
@@ -225,9 +228,9 @@ export const isMultiLine = createTypeChecker([
225
228
  ['-', isSimpleAndObject],
226
229
  ['-', isSiblingIsArray],
227
230
  ['-', isStringsInsideArray],
231
+ ['-', isNumbersArray],
228
232
  ['+', tooLong],
229
233
  ['+', isCoupleLines],
230
- ['-', isNumbersArray],
231
234
  ]);
232
235
 
233
236
  function isOneSimple(path) {
@@ -342,4 +345,3 @@ export const isCurrentNewLine = createTypeChecker([
342
345
  '+: -> SpreadElement',
343
346
  '+: -> !ObjectExpression',
344
347
  ]);
345
-
@@ -10,13 +10,13 @@ export const instrument = (typeNames, fn, overrides = {}) => {
10
10
  const {
11
11
  env = _env,
12
12
  coverage = Coverage,
13
- instrument = true,
13
+ instrumentName = 'TYPE_CHECK',
14
14
  } = overrides;
15
15
 
16
16
  const {length} = typeNames;
17
17
  const error = Error();
18
18
  const location = parseCallLocation(error);
19
- const on = instrument && env.TYPE_CHECK;
19
+ const on = env[instrumentName];
20
20
  const covered = new Set();
21
21
 
22
22
  if (on && !location.includes('type-checker.spec.js'))
@@ -0,0 +1,81 @@
1
+ import {styleText} from 'node:util';
2
+ import {codeFrameColumns} from '@putout/babel';
3
+
4
+ /* c8 ignore start */
5
+ const isString = (a) => typeof a === 'string';
6
+ const isFn = (a) => typeof a === 'function';
7
+ const difference = (a, b) => new Set(a).difference(new Set(b));
8
+ const red = (a) => styleText('red', String(a));
9
+
10
+ const SUCCESS = 0;
11
+ const FAIL = 1;
12
+
13
+ export const report = (coverage) => {
14
+ const lines = [];
15
+ const log = (a) => lines.push(a);
16
+ let exitCode = SUCCESS;
17
+
18
+ for (const [name, {length, covered, typeNames}] of coverage) {
19
+ if (length === covered.size)
20
+ continue;
21
+
22
+ for (const index of difference(fullSet(length), covered)) {
23
+ const currentType = typeNames[index];
24
+ const rawCode = createRawCode(currentType);
25
+ const code = codeFrameColumns(rawCode, {}, {
26
+ forceColor: true,
27
+ });
28
+
29
+ log(`🧨 Uncovered Checkers found at index: ${red(index + 1)}`);
30
+ log(`${code}\n`);
31
+ log(`${setLine(name, index)}\n`);
32
+ exitCode = FAIL;
33
+ }
34
+ }
35
+
36
+ if (exitCode === SUCCESS)
37
+ log('# 🌴 Checkers Covered');
38
+
39
+ return [exitCode, lines.join('\n')];
40
+ };
41
+
42
+ const setLine = (name, index) => {
43
+ const [at, uri, line, column] = name.split(':');
44
+ const newLine = Number(line) + index + 1;
45
+
46
+ return [
47
+ at,
48
+ uri,
49
+ newLine,
50
+ column,
51
+ ].join(':');
52
+ };
53
+
54
+ const fullSet = (n) => {
55
+ const result = new Set();
56
+ let i = 0;
57
+
58
+ do {
59
+ result.add(i++);
60
+ } while (i < n);
61
+
62
+ return result;
63
+ };
64
+
65
+ function createRawCode(currentType) {
66
+ if (isString(currentType))
67
+ return currentType;
68
+
69
+ if (isFn(currentType))
70
+ return currentType.name;
71
+
72
+ const [operator, fn] = currentType;
73
+
74
+ if (fn) {
75
+ const name = fn.name || fn;
76
+ return `['${operator}', ${name}]`;
77
+ }
78
+
79
+ return operator;
80
+ }/* c8 ignore end */
81
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.2.2",
3
+ "version": "18.2.4",
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",
@@ -10,7 +10,9 @@
10
10
  ".": "./lib/printer.js",
11
11
  "./is": "./lib/tokenize/is.js",
12
12
  "./params": "./lib/tokenize/expressions/function/params.js",
13
- "./type-checker": "./lib/tokenize/type-checker/type-checker.js"
13
+ "./type-checker": "./lib/tokenize/type-checker/type-checker.js",
14
+ "./type-checker/instrument": "./lib/tokenize/type-checker/instrument.js",
15
+ "./type-checker/report": "./lib/tokenize/type-checker/report.js"
14
16
  },
15
17
  "repository": {
16
18
  "type": "git",
@@ -65,7 +67,8 @@
65
67
  "#import-attributes": "./lib/tokenize/statements/import-declaration/import-attribute.js",
66
68
  "#types": "./lib/types.js",
67
69
  "#type-checker": "./lib/tokenize/type-checker/type-checker.js",
68
- "#type-checker/instrument": "./lib/tokenize/type-checker/instrument.js"
70
+ "#type-checker/instrument": "./lib/tokenize/type-checker/instrument.js",
71
+ "#type-checker/report": "./lib/tokenize/type-checker/report.js"
69
72
  },
70
73
  "devDependencies": {
71
74
  "@babel/parser": "^7.28.5",
@@ -98,7 +101,7 @@
98
101
  },
99
102
  "license": "MIT",
100
103
  "engines": {
101
- "node": ">=22"
104
+ "node": ">=22.13"
102
105
  },
103
106
  "publishConfig": {
104
107
  "access": "public"