UNPKG

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