@putout/printer 18.4.7 → 18.5.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
CHANGED
|
@@ -9,12 +9,7 @@ import {
|
|
|
9
9
|
isTrailingCommaOption,
|
|
10
10
|
} from './is.js';
|
|
11
11
|
|
|
12
|
-
const {
|
|
13
|
-
isSpreadElement,
|
|
14
|
-
isCallExpression,
|
|
15
|
-
isObjectExpression,
|
|
16
|
-
isIdentifier,
|
|
17
|
-
} = types;
|
|
12
|
+
const {isObjectExpression} = types;
|
|
18
13
|
|
|
19
14
|
const isCommaAfterElementByOption = createTypeChecker([
|
|
20
15
|
['+: -> !', isLastOption],
|
|
@@ -35,9 +30,9 @@ export const isNewlineAfterComma = createTypeChecker([
|
|
|
35
30
|
|
|
36
31
|
const isSimpleBetweenObjects = createTypeChecker([
|
|
37
32
|
['+', callWithNext(isObjectExpression)],
|
|
38
|
-
['
|
|
39
|
-
['
|
|
40
|
-
['+: -> !'
|
|
33
|
+
['-: SpreadElement'],
|
|
34
|
+
['-: Identifier'],
|
|
35
|
+
['+: -> !CallExpression'],
|
|
41
36
|
]);
|
|
42
37
|
|
|
43
38
|
export const isSpaceAfterComa = createTypeChecker([
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {types} from '@putout/babel';
|
|
2
1
|
import {createTypeChecker} from '#type-checker';
|
|
3
2
|
|
|
4
|
-
const {isBinaryExpression} = types;
|
|
5
3
|
const isPlus = (a) => a === '+';
|
|
6
4
|
|
|
7
5
|
export const isConcatenation = createTypeChecker([
|
|
8
6
|
['-: node.operator -> !', isPlus],
|
|
9
7
|
['-: node.loc', isSameLine],
|
|
10
|
-
['
|
|
8
|
+
['+: BinaryExpression'],
|
|
11
9
|
]);
|
|
12
10
|
|
|
13
11
|
function isSameLine(loc) {
|
|
@@ -20,40 +20,28 @@ const parseResult = (a) => a === '+';
|
|
|
20
20
|
export function parseTypeNames(typeNames) {
|
|
21
21
|
const tuples = [];
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const tuple = createTuple(first);
|
|
28
|
-
|
|
29
|
-
tuples.push(tuple);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
23
|
+
for (const typeName of typeNames) {
|
|
24
|
+
if (isArray(typeName) && typeName.length === 1) {
|
|
25
|
+
const [first] = typeName;
|
|
26
|
+
const tuple = createTuple(first);
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
tuples.push(
|
|
28
|
+
tuples.push(tuple);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isArray(typeName)) {
|
|
33
|
+
tuples.push(typeName);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (isString(typeName) && typeName.includes(' -> ')) {
|
|
38
|
+
const tuple = createTuple(typeName);
|
|
39
|
+
tuples.push(tuple);
|
|
40
|
+
continue;
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
return tuples;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
for (const typeName of typeNames.include) {
|
|
51
43
|
tuples.push(['+', typeName]);
|
|
52
44
|
}
|
|
53
45
|
|
|
54
|
-
for (const typeName of typeNames.exclude) {
|
|
55
|
-
tuples.push(['-', typeName]);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
46
|
return tuples;
|
|
59
47
|
}
|
package/package.json
CHANGED