Babel.config.js
ignore: [/[\/\\]core-js/, /@babel[\/\\]runtime/],
cmd
jscodeshift -t ./transform.js ./src/**/* --extensions=js
// run prettier after
const mods = {
quote: 'single',
lineTerminator: "\n"
}
const recastMods = {}
export default (fileInfo, api) => {
const j = api.jscodeshift;
const root = j(fileInfo.source);
const MODULE_NAME = 'DropdownButton';
const rename = [
{ old: 'buttonTheme', new: 'theme' },
{ old: 'buttonIcon', new: 'icon' },
{ old: 'buttonText', new: 'text' },
];
const comp = root.findJSXElements(MODULE_NAME);
if (comp) {
rename.forEach(data => {
comp
.find(j.JSXIdentifier, {
name: data.old,
})
.replaceWith(data.new);
});
return root.toSource(mods);
}
};
// export default (fileInfo, api) => {
// const j = api.jscodeshift;
// const root = j(fileInfo.source);
// const tester = root
// .find(j.CallExpression, {
// callee: {
// type: 'MemberExpression',
// object: { type: 'Identifier', name: 'console' },
// },
// })
// //.remove()
// if(tester) {
// tester.remove();
// return root.toSource(mods);
// }
// };