UNPKG

1.62 kBSource Map (JSON)View Raw
1{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { ConfigAPI, types as t, NodePath } from '@babel/core'\n\nexport interface Options {\n elements: string[]\n attributes: string[]\n}\n\nconst removeJSXAttribute = (_: ConfigAPI, opts: Options) => ({\n visitor: {\n JSXOpeningElement(path: NodePath<t.JSXOpeningElement>) {\n if (!t.isJSXIdentifier(path.node.name)) return\n if (!opts.elements.includes(path.node.name.name)) return\n\n // @ts-ignore\n path.get('attributes').forEach((attribute) => {\n if (\n t.isJSXAttribute(attribute.node) &&\n t.isJSXIdentifier(attribute.node.name) &&\n opts.attributes.includes(attribute.node.name.name)\n ) {\n attribute.remove()\n }\n })\n },\n },\n})\n\nexport default removeJSXAttribute\n"],"names":["t"],"mappings":";;;;AACK,MAAC,kBAAkB,GAAG,CAAC,CAAC,EAAE,IAAI,MAAM;AACzC,EAAE,OAAO,EAAE;AACX,IAAI,iBAAiB,CAAC,IAAI,EAAE;AAC5B,MAAM,IAAI,CAACA,UAAC,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5C,QAAQ,OAAO;AACf,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACtD,QAAQ,OAAO;AACf,MAAM,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK;AACpD,QAAQ,IAAIA,UAAC,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,IAAIA,UAAC,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AAC9I,UAAU,SAAS,CAAC,MAAM,EAAE,CAAC;AAC7B,SAAS;AACT,OAAO,CAAC,CAAC;AACT,KAAK;AACL,GAAG;AACH,CAAC;;;;"}
\No newline at end of file