@yandex/ui
Version:
Yandex UI components
16 lines (14 loc) • 562 B
JavaScript
module.exports.removeImport = (root, j, library, valueImport) => {
root.find(j.ImportDeclaration)
// Find only library NodePaths
.filter((nodePath) => {
return nodePath.value.source.value.startsWith(library);
})
.forEach((nodePath) => {
const specifiers = nodePath.value.specifiers || [];
const cleanedImports = specifiers.filter((s) => {
return !s.imported.name.includes(valueImport);
});
nodePath.value.specifiers = cleanedImports;
});
};