UNPKG

@yandex/ui

Version:

Yandex UI components

23 lines (18 loc) 899 B
import { filterIdentifier } from './filterIdentifier'; import { filterCompose } from './filterCompose'; module.exports.removeUsage = (root, j, identifier) => { root.find(j.CallExpression) .forEach((nodePath) => { const args = nodePath.value.arguments; // вложенные вызовы const innerFunctions = args.filter((arg) => { return arg.type === 'CallExpression'; }); // обрабатываем вложенные функции innerFunctions.forEach((inF) => { inF.arguments = filterIdentifier(inF.arguments, identifier); }); // обрабатываем переданные аргумент и пустые compose/composeU после чистки выше nodePath.value.arguments = filterCompose(args, identifier); }); };