@putout/printer 18.14.0 → 18.16.0
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 +10 -0
- package/lib/tokenize/expressions/index.js +1 -1
- package/lib/tokenize/expressions/new-expression/new-expression.js +11 -38
- package/lib/tokenize/expressions/tagged-template-expression/tagged-template-expression.js +10 -0
- package/package.json +1 -1
- package/lib/tokenize/expressions/tagged-template-expression.js +0 -4
package/ChangeLog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2026.06.05, v18.16.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 7c522eae @putout/printer: NewExpression: parens: simplify
|
|
5
|
+
|
|
6
|
+
2026.06.05, v18.15.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 7d90cdac @putout/printer: TaggedTemplateExpression: parens: improve support
|
|
10
|
+
|
|
1
11
|
2026.06.05, v18.14.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -14,7 +14,7 @@ export {AssignmentPattern} from './assignment-pattern.js';
|
|
|
14
14
|
export {RestElement} from './rest-element.js';
|
|
15
15
|
export {SpreadElement} from './spread-element/spread-element.js';
|
|
16
16
|
export {SequenceExpression} from './sequence-expression/sequence-expression.js';
|
|
17
|
-
export {TaggedTemplateExpression} from './tagged-template-expression.js';
|
|
17
|
+
export {TaggedTemplateExpression} from './tagged-template-expression/tagged-template-expression.js';
|
|
18
18
|
export {BinaryExpression} from './binary-expression/binary-expression.js';
|
|
19
19
|
export {LogicalExpression} from './logical-expression/logical-expression.js';
|
|
20
20
|
export {ConditionalExpression} from './conditional-expression.js';
|
|
@@ -1,47 +1,20 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
|
-
import {
|
|
3
|
-
exists,
|
|
4
|
-
isInsideExpression,
|
|
5
|
-
} from '#is';
|
|
6
|
-
import {isMarkedAfter} from '#mark';
|
|
2
|
+
import {maybeParens} from '#maybe-parens';
|
|
7
3
|
|
|
8
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
isMemberExpression,
|
|
6
|
+
isClassDeclaration,
|
|
7
|
+
} = types;
|
|
9
8
|
|
|
10
|
-
const notFirst = ({parentPath}) => exists(parentPath.getPrevSibling());
|
|
11
9
|
const isInsideMember = ({parentPath}) => isMemberExpression(parentPath);
|
|
12
10
|
|
|
13
|
-
const
|
|
14
|
-
const prev = parentPath.getPrevSibling();
|
|
15
|
-
|
|
16
|
-
return [
|
|
17
|
-
prev.node,
|
|
18
|
-
prev,
|
|
19
|
-
];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const NewExpression = {
|
|
23
|
-
beforeIf(path) {
|
|
24
|
-
if (!isInsideExpression(path))
|
|
25
|
-
return false;
|
|
26
|
-
|
|
27
|
-
const [exists, prev] = getPrev(path);
|
|
28
|
-
|
|
29
|
-
if (!exists)
|
|
30
|
-
return false;
|
|
31
|
-
|
|
32
|
-
if (isMarkedAfter(prev))
|
|
33
|
-
return false;
|
|
34
|
-
|
|
35
|
-
if (prev.isExpressionStatement())
|
|
36
|
-
return false;
|
|
37
|
-
|
|
38
|
-
return notFirst(path);
|
|
39
|
-
},
|
|
40
|
-
before(path, {print}) {
|
|
41
|
-
print.breakline();
|
|
42
|
-
},
|
|
11
|
+
export const NewExpression = maybeParens({
|
|
43
12
|
print(path, printer, semantics) {
|
|
44
13
|
const {print, maybe} = printer;
|
|
14
|
+
const prev = path.parentPath.getPrevSibling();
|
|
15
|
+
|
|
16
|
+
maybe.print.breakline(isClassDeclaration(prev));
|
|
17
|
+
|
|
45
18
|
print('new ');
|
|
46
19
|
print('__callee');
|
|
47
20
|
print('__typeArguments');
|
|
@@ -58,7 +31,7 @@ export const NewExpression = {
|
|
|
58
31
|
|
|
59
32
|
maybePrintCloseBrace(path, printer, semantics);
|
|
60
33
|
},
|
|
61
|
-
};
|
|
34
|
+
});
|
|
62
35
|
|
|
63
36
|
function maybePrintOpenBrace(path, printer, semantics) {
|
|
64
37
|
maybePrintBrace('(', path, printer, semantics);
|
package/package.json
CHANGED