HACKER Q&A
📣 bryanrasmussen

Automate Rewrite of JSX


The project I'm on has used a UI library, and is now thoroughly locked in and I cannot stand it.

I would like to be able to write a script that will go through the codebase and change code without having to do the onerous job of doing it all by hand.

It would be working basically like if I could write XSLT to rewrite JSX.

So if I had some components like

then one could write code like (pseudo)

match = Button

className = apply-templates match="@*" mode = "className"

return


  👤 bryanrasmussen Accepted Answer ✓
obviously in the interest of saving time I have not written the example code to handle the actual className generating.