Skip to content

Commit a79a2ac

Browse files
committed
fix
1 parent 3430995 commit a79a2ac

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/plugins/installer/json.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function installPluginForJson(
77
configText: string,
88
plugins: Plugin[],
99
): ConfigInstallPluginResult {
10-
let config: Linter.Config;
10+
let config: Linter.LegacyConfig;
1111
try {
1212
config = JSON.parse(configText);
1313
} catch {

src/plugins/installer/new-config.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function margeImport(
194194
usedIds.add(name);
195195
}
196196
} else {
197-
const node = findNamedImport(spec.imported.name);
197+
const node = findNamedImport(getName(spec.imported));
198198
if (node) {
199199
localNames[spec.local.name] = node.spec.local.name;
200200
} else {
@@ -207,7 +207,7 @@ function margeImport(
207207
type: "ImportSpecifier",
208208
imported: {
209209
type: "Identifier",
210-
name: spec.imported.name,
210+
name: getName(spec.imported),
211211
},
212212
local: {
213213
type: "Identifier",
@@ -260,7 +260,8 @@ function margeImport(
260260
for (const node of iterateImport()) {
261261
const spec = node.specifiers.find(
262262
(spec): spec is ESTree.ImportSpecifier =>
263-
spec.type === "ImportSpecifier" && spec.imported.name === imported,
263+
spec.type === "ImportSpecifier" &&
264+
getName(spec.imported) === imported,
264265
);
265266
if (spec) {
266267
return { decl: node, spec };
@@ -309,7 +310,7 @@ function margeRequire(
309310
} else if (spec.type === "ImportDefaultSpecifier") {
310311
importedName = "default";
311312
} else {
312-
importedName = spec.imported.name;
313+
importedName = getName(spec.imported);
313314
}
314315
const preferName: string = spec.local.name;
315316
if (requireNode.type === "Identifier") {
@@ -456,3 +457,7 @@ function resolveName(name: string, usedIds: Set<string>) {
456457
}
457458
return resolved;
458459
}
460+
461+
function getName(node: ESTree.Identifier | ESTree.Literal): string {
462+
return node.type === "Identifier" ? node.name : String(node.value);
463+
}

0 commit comments

Comments
 (0)