JS: rename variables for refactor (using an AST, not text)
问题 I often need to rename variables when refactoring code, which I currently do in a somewhat hacky way using regexs - I end up having to come with silly text workaround workarounds for the lack of actual structure, eg, rename 'req' to 'request' and avoid side effects with similar names like 'require'. Thinking about this stuff: it's kind of like modifying the DOM with regexs: it just doesn't work. I've learnt about ASTs and code structure modification tools like Esprima. Is there a tool to