This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
import { ConfigAPI, NodePath, types } from '@babel/core';
interface Options {
elements: string[];
attributes: string[];
}
declare const removeJSXAttribute: (_: ConfigAPI, opts: Options) => {
visitor: {
JSXOpeningElement(path: NodePath<types.JSXOpeningElement>): void;
};
};
export { Options, removeJSXAttribute as default };

View File

@@ -0,0 +1,22 @@
'use strict';
var core = require('@babel/core');
const removeJSXAttribute = (_, opts) => ({
visitor: {
JSXOpeningElement(path) {
if (!core.types.isJSXIdentifier(path.node.name))
return;
if (!opts.elements.includes(path.node.name.name))
return;
path.get("attributes").forEach((attribute) => {
if (core.types.isJSXAttribute(attribute.node) && core.types.isJSXIdentifier(attribute.node.name) && opts.attributes.includes(attribute.node.name.name)) {
attribute.remove();
}
});
}
}
});
module.exports = removeJSXAttribute;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +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":";;;;AAQM,MAAA,kBAAA,GAAqB,CAAC,CAAA,EAAc,IAAmB,MAAA;AAAA,EAC3D,OAAS,EAAA;AAAA,IACP,kBAAkB,IAAqC,EAAA;AACrD,MAAA,IAAI,CAACA,UAAA,CAAE,eAAgB,CAAA,IAAA,CAAK,KAAK,IAAI,CAAA;AAAG,QAAA,OAAA;AACxC,MAAA,IAAI,CAAC,IAAK,CAAA,QAAA,CAAS,SAAS,IAAK,CAAA,IAAA,CAAK,KAAK,IAAI,CAAA;AAAG,QAAA,OAAA;AAGlD,MAAA,IAAA,CAAK,GAAI,CAAA,YAAY,CAAE,CAAA,OAAA,CAAQ,CAAC,SAAc,KAAA;AAC5C,QAAA,IACEA,WAAE,cAAe,CAAA,SAAA,CAAU,IAAI,CAC/B,IAAAA,UAAA,CAAE,gBAAgB,SAAU,CAAA,IAAA,CAAK,IAAI,CAAA,IACrC,KAAK,UAAW,CAAA,QAAA,CAAS,UAAU,IAAK,CAAA,IAAA,CAAK,IAAI,CACjD,EAAA;AACA,UAAA,SAAA,CAAU,MAAO,EAAA,CAAA;AAAA,SACnB;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,GACF;AACF,CAAA;;;;"}