@navikt/aksel
Version:
Aksel command line interface. Codemods and other utilities for Aksel users.
17 lines (16 loc) • 659 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = removePropsFromComponent;
function removePropsFromComponent(j, root, componentName, propsToRemove) {
const component = root.findJSXElements(componentName);
component.forEach((node) => {
const attributes = node.node.openingElement.attributes;
for (let i = attributes.length - 1; i >= 0; i--) {
const attribute = attributes[i];
if (attribute.type === "JSXAttribute" &&
propsToRemove.includes(attribute.name.name.toString())) {
attributes.splice(i, 1);
}
}
});
}