index.js 632 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var core = require('@babel/core');
  3. const removeJSXAttribute = (_, opts) => ({
  4. visitor: {
  5. JSXOpeningElement(path) {
  6. if (!core.types.isJSXIdentifier(path.node.name))
  7. return;
  8. if (!opts.elements.includes(path.node.name.name))
  9. return;
  10. path.get("attributes").forEach((attribute) => {
  11. if (core.types.isJSXAttribute(attribute.node) && core.types.isJSXIdentifier(attribute.node.name) && opts.attributes.includes(attribute.node.name.name)) {
  12. attribute.remove();
  13. }
  14. });
  15. }
  16. }
  17. });
  18. module.exports = removeJSXAttribute;
  19. //# sourceMappingURL=index.js.map