@putout/printer 2.13.1 → 2.15.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
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2023.06.14, v2.15.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- e714be8 @putout/printer: ImportDeclaration: indent
|
|
5
|
+
|
|
6
|
+
2023.06.14, v2.14.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 0f3dbaf @putout/printer: ArrayExpression: no newline when one element with type SpreadElement
|
|
10
|
+
|
|
1
11
|
2023.06.14, v2.13.1
|
|
2
12
|
|
|
3
13
|
fix:
|
|
@@ -11,6 +11,7 @@ const {
|
|
|
11
11
|
isBooleanLiteral,
|
|
12
12
|
isNullLiteral,
|
|
13
13
|
isStringLiteral,
|
|
14
|
+
isSpreadElement,
|
|
14
15
|
} = require('@babel/types');
|
|
15
16
|
|
|
16
17
|
const {
|
|
@@ -24,6 +25,15 @@ const {
|
|
|
24
25
|
|
|
25
26
|
const {round} = Math;
|
|
26
27
|
|
|
28
|
+
const isOneSpread = (elements) => {
|
|
29
|
+
if (elements.length > 1)
|
|
30
|
+
return false;
|
|
31
|
+
|
|
32
|
+
const [first] = elements;
|
|
33
|
+
|
|
34
|
+
return isSpreadElement(first);
|
|
35
|
+
};
|
|
36
|
+
|
|
27
37
|
const isSimpleAndCall = ([a, b]) => {
|
|
28
38
|
if (!isSimple(a))
|
|
29
39
|
return;
|
|
@@ -44,6 +54,9 @@ module.exports.isNewlineBetweenElements = (path, {elements, maxElementsInOneLine
|
|
|
44
54
|
if (isOneSimple(path))
|
|
45
55
|
return ONE_LINE;
|
|
46
56
|
|
|
57
|
+
if (isOneSpread(elements))
|
|
58
|
+
return ONE_LINE;
|
|
59
|
+
|
|
47
60
|
if (elements.length === 2 && isIdentifierAndIdentifier(elements))
|
|
48
61
|
return ONE_LINE;
|
|
49
62
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {markAfter} = require('../../mark');
|
|
4
|
-
const {isLast} = require('../../is');
|
|
4
|
+
const {isLast, isNext} = require('../../is');
|
|
5
5
|
const {parseImportSpecifiers} = require('parse-import-specifiers');
|
|
6
6
|
|
|
7
7
|
const {
|
|
@@ -16,8 +16,9 @@ module.exports.ImportDeclaration = {
|
|
|
16
16
|
const specifiers = path.get('specifiers');
|
|
17
17
|
const {maxSpecifiersInOneLine} = options;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
indent();
|
|
20
|
+
write('import');
|
|
21
|
+
maybe.write(isType, ' type');
|
|
21
22
|
|
|
22
23
|
let wasSpecifier = false;
|
|
23
24
|
const n = specifiers.length - 1;
|
|
@@ -28,7 +29,7 @@ module.exports.ImportDeclaration = {
|
|
|
28
29
|
imports,
|
|
29
30
|
} = parseImportSpecifiers(specifiers);
|
|
30
31
|
|
|
31
|
-
maybe.
|
|
32
|
+
maybe.write(specifiers.length, ' ');
|
|
32
33
|
|
|
33
34
|
for (const spec of defaults) {
|
|
34
35
|
traverse(spec.get('local'));
|
|
@@ -37,8 +38,8 @@ module.exports.ImportDeclaration = {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
for (const spec of namespaces) {
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
write('* as ');
|
|
42
|
+
traverse(spec.get('local'));
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
const importsCount = imports.length - 1;
|
|
@@ -79,7 +80,7 @@ module.exports.ImportDeclaration = {
|
|
|
79
80
|
maybe.write(last, '}');
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
maybe.
|
|
83
|
+
maybe.write(specifiers.length, ' from');
|
|
83
84
|
print.space();
|
|
84
85
|
|
|
85
86
|
print('__source');
|
|
@@ -89,7 +90,7 @@ module.exports.ImportDeclaration = {
|
|
|
89
90
|
});
|
|
90
91
|
print(';');
|
|
91
92
|
|
|
92
|
-
if (
|
|
93
|
+
if (isNext(path))
|
|
93
94
|
print.newline();
|
|
94
95
|
},
|
|
95
96
|
afterIf(path) {
|
package/package.json
CHANGED