UNPKG

aws-sdk-js-codemod

Version:

Collection of codemod scripts that help update AWS SDK for JavaScript APIs

18 lines (17 loc) 649 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.removeDeclaration = void 0; /** * Removes import/variable declaration, but preserves comments if they're top level comments. */ const removeDeclaration = (j, source, declarationPath) => { const firstNode = source.find(j.Program).get("body", 0).node; if (firstNode === declarationPath.node) { const { comments } = declarationPath.value; if (comments?.length) { declarationPath.insertBefore(j.emptyStatement.from({ comments })); } } j(declarationPath).remove(); }; exports.removeDeclaration = removeDeclaration;