@putout/printer 8.24.0 → 8.25.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
|
@@ -12,7 +12,15 @@ const {
|
|
|
12
12
|
|
|
13
13
|
module.exports.ImportAttribute = ImportAttribute;
|
|
14
14
|
module.exports.ImportDeclaration = {
|
|
15
|
-
print(path,
|
|
15
|
+
print(path, printer, semantics) {
|
|
16
|
+
const {
|
|
17
|
+
print,
|
|
18
|
+
maybe,
|
|
19
|
+
write,
|
|
20
|
+
traverse,
|
|
21
|
+
indent,
|
|
22
|
+
} = printer;
|
|
23
|
+
|
|
16
24
|
const {phase} = path.node;
|
|
17
25
|
const isType = path.node.importKind === 'type';
|
|
18
26
|
const specifiers = path.get('specifiers');
|
|
@@ -44,7 +52,7 @@ module.exports.ImportDeclaration = {
|
|
|
44
52
|
traverse(spec.get('local'));
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
const maxSpecifiersInOneLine = parseMaxSpecifiers(imports,
|
|
55
|
+
const maxSpecifiersInOneLine = parseMaxSpecifiers(imports, semantics);
|
|
48
56
|
const importsCount = imports.length - 1;
|
|
49
57
|
|
|
50
58
|
for (const [index, spec] of imports.entries()) {
|
|
@@ -75,9 +83,9 @@ module.exports.ImportDeclaration = {
|
|
|
75
83
|
maybe.write(n, ',');
|
|
76
84
|
|
|
77
85
|
const last = index === n;
|
|
78
|
-
const
|
|
86
|
+
const penulty = index === n - 1;
|
|
79
87
|
|
|
80
|
-
maybe.write.newline(
|
|
88
|
+
maybe.write.newline(penulty && defaults.length);
|
|
81
89
|
maybe.write.newline(last);
|
|
82
90
|
}
|
|
83
91
|
|
|
@@ -110,12 +118,18 @@ module.exports.ImportDeclaration = {
|
|
|
110
118
|
},
|
|
111
119
|
};
|
|
112
120
|
|
|
113
|
-
function parseMaxSpecifiers(imports,
|
|
114
|
-
const {
|
|
121
|
+
function parseMaxSpecifiers(imports, semantics) {
|
|
122
|
+
const {
|
|
123
|
+
maxSpecifiersInOneLine,
|
|
124
|
+
maxPropertiesLengthInOneLine,
|
|
125
|
+
} = semantics;
|
|
115
126
|
|
|
116
127
|
for (const {node} of imports) {
|
|
117
128
|
if (node.imported.name !== node.local.name)
|
|
118
129
|
return 1;
|
|
130
|
+
|
|
131
|
+
if (node.imported.name.length >= maxPropertiesLengthInOneLine)
|
|
132
|
+
return 1;
|
|
119
133
|
}
|
|
120
134
|
|
|
121
135
|
return maxSpecifiersInOneLine;
|
package/package.json
CHANGED