@putout/printer 18.6.4 → 18.6.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
|
@@ -11,18 +11,27 @@ import {
|
|
|
11
11
|
callWithPrev,
|
|
12
12
|
} from '#is';
|
|
13
13
|
|
|
14
|
-
const isTwoLinesDifferenceWithPrev = (path) => {
|
|
15
|
-
const prev = path.getPrevSibling();
|
|
16
|
-
|
|
17
|
-
return path.node.loc?.start.line === prev.node?.loc?.start?.line + 2;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
14
|
const {
|
|
21
15
|
isIfStatement,
|
|
22
16
|
isFunctionDeclaration,
|
|
23
17
|
isVariableDeclaration,
|
|
18
|
+
isExpressionStatement,
|
|
19
|
+
isAssignmentExpression,
|
|
24
20
|
} = types;
|
|
25
21
|
|
|
22
|
+
const issLessThenThree = (a) => a < 3;
|
|
23
|
+
const callWithExpression = (fn) => (path) => fn(path.node.expression);
|
|
24
|
+
|
|
25
|
+
const isTwoLinesDifferenceWithPrev = (path) => {
|
|
26
|
+
const prev = path.getPrevSibling();
|
|
27
|
+
return path.node.loc?.start.line === prev.node?.loc?.start?.line + 2;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const isInsideBlockWithLessThenThreeSiblings = createTypeChecker([
|
|
31
|
+
['-: parentPath -> !BlockStatement'],
|
|
32
|
+
['+: parentPath.node.body.length', issLessThenThree],
|
|
33
|
+
]);
|
|
34
|
+
|
|
26
35
|
const notLastPrevVarNotNextVar = createTypeChecker([
|
|
27
36
|
['-: -> !', callWithPrev(exists)],
|
|
28
37
|
['-', isTwoLinesDifferenceWithPrev],
|
|
@@ -52,19 +61,11 @@ const notLastCoupleLines = createTypeChecker([
|
|
|
52
61
|
['+', isCoupleLines],
|
|
53
62
|
]);
|
|
54
63
|
|
|
55
|
-
const isNextAssign = (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const {parentPath} = path;
|
|
62
|
-
|
|
63
|
-
if (parentPath.isBlockStatement() && parentPath.node.body.length < 3)
|
|
64
|
-
return false;
|
|
65
|
-
|
|
66
|
-
return nextPath.get('expression').isAssignmentExpression();
|
|
67
|
-
};
|
|
64
|
+
const isNextAssign = createTypeChecker([
|
|
65
|
+
['-: -> !', callWithNext(isExpressionStatement)],
|
|
66
|
+
['-', isInsideBlockWithLessThenThreeSiblings],
|
|
67
|
+
['+', callWithNext(callWithExpression(isAssignmentExpression))],
|
|
68
|
+
]);
|
|
68
69
|
|
|
69
70
|
export const afterIf = createTypeChecker([
|
|
70
71
|
['+', callWithNext(isIfStatement)],
|
|
@@ -78,4 +79,3 @@ export const afterIf = createTypeChecker([
|
|
|
78
79
|
['+: parentPath -> ExportNamedDeclaration'],
|
|
79
80
|
['+: parentPath -> TSModuleBlock'],
|
|
80
81
|
]);
|
|
81
|
-
|
package/package.json
CHANGED