import type { Collection, ImportDeclaration, JSCodeshift } from 'jscodeshift'; export const getImportDeclarationCollection = ({ j, collection, importPath, }: { j: JSCodeshift; collection: Collection; importPath: string; }): Collection => { const found: Collection = collection .find(j.ImportDeclaration) .filter((importDeclarationPath) => importDeclarationPath.node.source.value === importPath); return found; }; export const hasImportDeclaration = ({ j, collection, importPath, }: { j: JSCodeshift; collection: Collection; importPath: string; }): boolean => { const result: Collection = getImportDeclarationCollection({ j, collection, importPath, }); return result.length > 0; };