@putout/printer 18.0.11 → 18.0.13
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
|
@@ -61,23 +61,18 @@ const isSiblingIsArray = (path) => {
|
|
|
61
61
|
|
|
62
62
|
const isEmptyArray = (path) => !path.node.elements.length;
|
|
63
63
|
|
|
64
|
-
const isAllLiterals = (path) => {
|
|
65
|
-
const {elements} = path.node;
|
|
66
|
-
const literals = elements.filter(isStringLiteral);
|
|
67
|
-
|
|
68
|
-
return literals.length !== elements.length;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
64
|
const isMoreThenMaxLiteralLength = (path, {maxElementLengthInOneLine}) => {
|
|
72
65
|
const [first] = path.node.elements;
|
|
73
66
|
|
|
67
|
+
if (!first.value)
|
|
68
|
+
return false;
|
|
69
|
+
|
|
74
70
|
return first.value.length > maxElementLengthInOneLine;
|
|
75
71
|
};
|
|
76
72
|
|
|
77
73
|
const isMoreThenMaxElementLengthInOneLine = createTypeChecker([
|
|
78
74
|
['-', isEmptyArray],
|
|
79
75
|
['-: -> !', isInsideCall],
|
|
80
|
-
['-', isAllLiterals],
|
|
81
76
|
['+', isMoreThenMaxLiteralLength],
|
|
82
77
|
]);
|
|
83
78
|
|
|
@@ -5,7 +5,6 @@ import {isNext, isNextParent} from '#is';
|
|
|
5
5
|
import {createTypeChecker} from '#type-checker';
|
|
6
6
|
|
|
7
7
|
const {
|
|
8
|
-
isAssignmentExpression,
|
|
9
8
|
isExportNamedDeclaration,
|
|
10
9
|
isExpressionStatement,
|
|
11
10
|
isFunctionDeclaration,
|
|
@@ -13,15 +12,24 @@ const {
|
|
|
13
12
|
|
|
14
13
|
const hasFnBody = ({node}) => node.body.body.length;
|
|
15
14
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const getNext = (fn) => (path) => fn(path.getNextSibling());
|
|
16
|
+
|
|
17
|
+
const isIndentAfter = createTypeChecker([
|
|
18
|
+
['+', getNext(isFunctionDeclaration)],
|
|
19
|
+
['+', isNext],
|
|
20
|
+
['-: -> !', getNext(isExpressionStatement)],
|
|
19
21
|
]);
|
|
20
22
|
|
|
21
|
-
const
|
|
23
|
+
const isNotInsideExportDefaultWithBody = createTypeChecker([
|
|
24
|
+
'+: parentPath -> !ExportDefaultDeclaration',
|
|
25
|
+
['+: -> !', hasFnBody],
|
|
26
|
+
]);
|
|
22
27
|
|
|
23
|
-
const
|
|
24
|
-
|
|
28
|
+
const isInsideBlockLike = createTypeChecker([
|
|
29
|
+
'+: parentPath.parentPath -> TSModuleBlock',
|
|
30
|
+
'-: parentPath -> !BlockStatement',
|
|
31
|
+
['+: -> !', hasFnBody],
|
|
32
|
+
]);
|
|
25
33
|
|
|
26
34
|
const isInsideNamedExport = ({parentPath}) => isExportNamedDeclaration(parentPath);
|
|
27
35
|
|
|
@@ -60,24 +68,10 @@ export const FunctionDeclaration = {
|
|
|
60
68
|
},
|
|
61
69
|
afterSatisfy: () => [isNext, isNextParent, isInsideBlockLike],
|
|
62
70
|
after(path, {indent, maybe}) {
|
|
63
|
-
if (
|
|
71
|
+
if (isIndentAfter(path))
|
|
64
72
|
indent();
|
|
65
73
|
|
|
66
|
-
maybe.write.newline(
|
|
74
|
+
maybe.write.newline(isNotInsideExportDefaultWithBody(path));
|
|
67
75
|
markAfter(path);
|
|
68
76
|
},
|
|
69
77
|
};
|
|
70
|
-
|
|
71
|
-
const isNextFunction = (path) => {
|
|
72
|
-
const next = path.getNextSibling();
|
|
73
|
-
return isFunctionDeclaration(next);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const isNextAssign = (path) => {
|
|
77
|
-
const next = path.getNextSibling();
|
|
78
|
-
|
|
79
|
-
if (!isExpressionStatement(next))
|
|
80
|
-
return false;
|
|
81
|
-
|
|
82
|
-
return isAssignmentExpression(next.node.expression);
|
|
83
|
-
};
|
package/package.json
CHANGED