@putout/printer 6.14.0 → 6.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/comment/parse-trailing-comments.js +6 -2
- package/lib/tokenize/expressions/class/class.js +1 -3
- package/lib/tokenize/expressions/member-expression/member-expressions.js +24 -2
- package/lib/tokenize/statements/if-statement/if-statement.js +0 -1
- package/lib/tokenize/statements/return-statement/return-statement.js +3 -0
- package/lib/tokenize/typescript/interface/ts-interface-declaration.js +1 -3
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2023.12.03, v6.16.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 27a2185 @putout/printer: ReturnStatement inside IfStatement: newline
|
|
5
|
+
|
|
6
|
+
2023.12.03, v6.15.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- f05ae8a @putout/printer: MemberExpression: chain inside ifStatement
|
|
10
|
+
|
|
1
11
|
2023.12.03, v6.14.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
isDecorator,
|
|
5
|
+
isMemberExpression,
|
|
6
|
+
} = require('@putout/babel').types;
|
|
7
|
+
|
|
4
8
|
const {
|
|
5
9
|
isLast,
|
|
6
10
|
isCoupleLines,
|
|
@@ -18,7 +22,7 @@ const isTrailingIsLeading = (path) => path.node.trailingComments === path.getNex
|
|
|
18
22
|
const isNewlineAfter = (path) => {
|
|
19
23
|
const {parentPath} = path;
|
|
20
24
|
|
|
21
|
-
if (
|
|
25
|
+
if (isMemberExpression(parentPath))
|
|
22
26
|
return false;
|
|
23
27
|
|
|
24
28
|
return !isLast(path) && !isDecorator(path);
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
const {
|
|
4
4
|
isUnaryExpression,
|
|
5
5
|
isArrowFunctionExpression,
|
|
6
|
-
isLogicalExpression,
|
|
7
6
|
isIfStatement,
|
|
8
7
|
} = require('@putout/babel').types;
|
|
9
8
|
|
|
@@ -65,10 +64,30 @@ const isCall = (a) => a.type === 'CallExpression';
|
|
|
65
64
|
const isExcludedFromChain = satisfy([
|
|
66
65
|
isUnaryExpression,
|
|
67
66
|
isArrowFunctionExpression,
|
|
68
|
-
isLogicalExpression,
|
|
69
67
|
isIfStatement,
|
|
70
68
|
]);
|
|
71
69
|
|
|
70
|
+
const isIfUp = (path) => {
|
|
71
|
+
const ifPath = path.find(isIfStatement);
|
|
72
|
+
let is = false;
|
|
73
|
+
|
|
74
|
+
if (!ifPath)
|
|
75
|
+
return is;
|
|
76
|
+
|
|
77
|
+
ifPath
|
|
78
|
+
.get('test')
|
|
79
|
+
.traverse({
|
|
80
|
+
MemberExpression(currentPath) {
|
|
81
|
+
if (path === currentPath) {
|
|
82
|
+
is = true;
|
|
83
|
+
path.stop();
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return is;
|
|
89
|
+
};
|
|
90
|
+
|
|
72
91
|
module.exports.likeChain = likeChain;
|
|
73
92
|
function likeChain(path) {
|
|
74
93
|
const [root, properties] = chain(path);
|
|
@@ -76,6 +95,9 @@ function likeChain(path) {
|
|
|
76
95
|
if (isExcludedFromChain(root))
|
|
77
96
|
return false;
|
|
78
97
|
|
|
98
|
+
if (path.find(isIfUp))
|
|
99
|
+
return false;
|
|
100
|
+
|
|
79
101
|
const calls = properties.filter(isCall);
|
|
80
102
|
const [firstCall] = calls;
|
|
81
103
|
|
|
@@ -4,7 +4,6 @@ const {markAfter} = require('../../mark');
|
|
|
4
4
|
const {exists, isNext} = require('../../is');
|
|
5
5
|
|
|
6
6
|
const isInside = ({parentPath}) => !parentPath.parentPath.isProgram();
|
|
7
|
-
|
|
8
7
|
const isEmptyConsequent = (path) => path.get('consequent').isEmptyStatement();
|
|
9
8
|
|
|
10
9
|
const isInsideNestedBody = ({parentPath}) => {
|
package/package.json
CHANGED