@putout/printer 18.42.0 → 18.42.2

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,13 @@
1
+ 2026.09.02, v18.42.2
2
+
3
+ feature:
4
+ - 455bdcf0 @putout/printer: ConditionalExpression: consequent is ObjectExpression: no multiline
5
+
6
+ 2026.08.31, v18.42.1
7
+
8
+ fix:
9
+ - 9ade0b23 @putout/printer: types: Printer
10
+
1
11
  2026.08.31, v18.42.0
2
12
 
3
13
  feature:
package/lib/printer.d.ts CHANGED
@@ -18,12 +18,9 @@ export interface Semantics {
18
18
  trailingComma: boolean;
19
19
  }
20
20
 
21
- export type Print = (input: string | Node) => void;
22
-
21
+ export type PrinterPrint = (input: string | Node) => void;
23
22
  export type Indent = () => void;
24
-
25
23
  export type Traverse = (input: Node) => void;
26
-
27
24
  export type MaybeCondition = (condition: boolean) => void;
28
25
 
29
26
  export type MaybeIndent = {
@@ -43,7 +40,7 @@ export interface Maybe {
43
40
  }
44
41
 
45
42
  export interface Printer {
46
- print: Print;
43
+ print: PrinterPrint;
47
44
  maybe: Maybe;
48
45
  indent: Indent;
49
46
  traverse: Traverse;
@@ -61,7 +58,8 @@ export interface Options {
61
58
  visitors?: Visitors;
62
59
  }
63
60
 
64
- export function print(ast: Node, options?: Options): string;
61
+ type Print = (ast: Node, options?: Options) => string;
62
+ export const print: Print;
65
63
 
66
- export declare function maybeVisitor(plugin: Visitor, path: Node, printer: Print, semantics: Semantics): void;
64
+ export declare function maybeVisitor(plugin: Visitor, path: Node, printer: Printer, semantics: Semantics): void;
67
65
  export const visitors: Visitors;
@@ -1,4 +1,13 @@
1
- export const ConditionalExpressionMultiline = (path, {print, indent}) => {
1
+ import {createTypeChecker} from '#type-checker';
2
+ import {isCoupleLines} from '#is';
3
+
4
+ export const isConditionalExpressionMultiline = createTypeChecker([
5
+ ['-: node.alternate -> ObjectExpression'],
6
+ ['-: node.consequent -> ObjectExpression'],
7
+ ['+', isCoupleLines],
8
+ ]);
9
+
10
+ export const printConditionalExpressionMultiline = (path, {print, indent}) => {
2
11
  print('__test');
3
12
  print.space();
4
13
  print('?');
@@ -11,3 +20,4 @@ export const ConditionalExpressionMultiline = (path, {print, indent}) => {
11
20
  indent.dec();
12
21
  print('__alternate');
13
22
  };
23
+
@@ -1,16 +1,14 @@
1
- import {types} from '@putout/babel';
2
1
  import {maybeParens} from '#maybe-parens';
3
- import {isCoupleLines} from '#is';
4
- import {ConditionalExpressionMultiline} from './conditional-expression-multiline.js';
5
-
6
- const {isObjectExpression} = types;
2
+ import {
3
+ isConditionalExpressionMultiline,
4
+ printConditionalExpressionMultiline,
5
+ } from './conditional-expression-multiline.js';
7
6
 
8
7
  export const ConditionalExpression = maybeParens((path, printer) => {
9
8
  const {print} = printer;
10
- const {alternate} = path.node;
11
9
 
12
- if (isCoupleLines(path) && !isObjectExpression(alternate)) {
13
- ConditionalExpressionMultiline(path, printer);
10
+ if (isConditionalExpressionMultiline(path)) {
11
+ printConditionalExpressionMultiline(path, printer);
14
12
  return;
15
13
  }
16
14
 
@@ -24,4 +22,3 @@ export const ConditionalExpression = maybeParens((path, printer) => {
24
22
  print.space();
25
23
  print('__alternate');
26
24
  });
27
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.42.0",
3
+ "version": "18.42.2",
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",