I have a minified javascript file. I can send it through a variety of tools to insert newlines and indentation. What I then want is to fix the variable names. I know that no tool can do this automatically. What I need is a tool that will augment my attempt to do so manually. It needs to be aware of scope rules so that when I rename c
to length
and d
to height
and j()
to move()
, those changes will be made everywhere that the same c
and d
and j
are used, but not in other scopes where different variables and functions with those same names exist.
Is there a tool like this, specifically designed for reversing minification? If there isn't a tool for this specific job, is there a smart IDE that can at least handle renaming variables or methods following scope rules?
I found an in-browser/downloadable node.js library tool that does rename refactoring very well. Esprima handles the following ES6 code (slightly modified from the example) such that when I change the name of any of the global scope
hi
, only thehi
names surrounded by a comment block are changed (I couldn't think of a better way to call out code since markdown doesn't show in code blocks, sorry).It seems to respect scoping rules as long as there are no code errors (for example, a
let
declaration above avar
declaration of the same name that gets hoisted above thelet
will be considered in-scope, but this is a non-issue since it's a syntax error).