Skip to content

Commit

Permalink
chore: remove redundant utility getImportSpecifier
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Feb 27, 2024
1 parent 23ed135 commit a4f5857
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
11 changes: 0 additions & 11 deletions src/transforms/v2-to-v3/modules/getImportSpecifier.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "jscodeshift";

import { OBJECT_PROPERTY_TYPE_LIST, PACKAGE_NAME } from "../../config";
import { getImportSpecifier } from "../getImportSpecifier";
import { getImportSpecifiers } from "../getImportSpecifiers";
import { getRequireProperty } from "../getRequireProperty";
import { importSpecifierCompareFn } from "../importSpecifierCompareFn";
Expand Down Expand Up @@ -101,15 +100,17 @@ export const addNamedModule = (
// Add named import to the first import declaration.
const firstImportDeclSpecifiers = importDeclarations.nodes()[0].specifiers;
if (firstImportDeclSpecifiers) {
firstImportDeclSpecifiers.push(getImportSpecifier(j, { importedName, localName }));
firstImportDeclSpecifiers.push(
j.importSpecifier(j.identifier(importedName), j.identifier(localName))
);
firstImportDeclSpecifiers.sort(importSpecifierCompareFn);
return;
}
}

// Build a new import declaration.
const v3ImportDeclaration = j.importDeclaration(
[getImportSpecifier(j, { importedName, localName })],
[j.importSpecifier(j.identifier(importedName), j.identifier(localName))],
j.stringLiteral(packageName)
);

Expand Down

0 comments on commit a4f5857

Please sign in to comment.