diff --git a/.changeset/perfect-parents-share.md b/.changeset/perfect-parents-share.md new file mode 100644 index 0000000000..6940d3dba9 --- /dev/null +++ b/.changeset/perfect-parents-share.md @@ -0,0 +1,5 @@ +--- +"@channel.io/bezier-codemod": patch +--- + +Fix `hasNamedImportInImportDeclaration` util to check all named imports diff --git a/packages/bezier-codemod/src/utils/import.ts b/packages/bezier-codemod/src/utils/import.ts index 5baf10d103..33efe21111 100644 --- a/packages/bezier-codemod/src/utils/import.ts +++ b/packages/bezier-codemod/src/utils/import.ts @@ -14,10 +14,10 @@ export const getImportDeclarations = (sourceFile: SourceFile, specifier: string) .filter((declaration) => declaration.getModuleSpecifier().getLiteralValue() === specifier) export const hasNamedImportInImportDeclaration = (sourceFile: SourceFile, namedImport: string, moduleName: string) => { - const importDeclaration = getImportDeclaration(sourceFile, moduleName) - return importDeclaration - ?.getNamedImports() - .map((node) => node.getText()) + const importDeclarations = getImportDeclarations(sourceFile, moduleName) + return importDeclarations + .flatMap(v => v?.getNamedImports()) + .map(v => v.getText()) .includes(namedImport) }