- write expected first, then write AST
- run test until match expectation
- AST explorer You can toggle the visibility of properties in AST Explorer with the checkboxes above the tree.
- GoGoCode PlayGround
-
js-codemod no-vars Convert all instances of "var" into either "let" or "const", based on the variable usage.
For example, "let" if the variable is reassigned at a later time and "const" when the variable is never reassigned.
-
js-codemod template-literals Replace instances of string concatenation with template literals e.g.
const sayHello = 'Hi my name is ' + name; // after transform const sayHello =
Hi my name is ${name}
;
var foo
foo = "foo"
var bar
bar = {foo: "foobar"}
var g
g = /abc/g
Improvements:
- Editor size should be full screen.
- Edit too quickly would fail to rename references.
- Edit after variable name does NOT take effect.
- Auto generate unique variable name.
Determineal: 0. Make sure there are not occurrens of "fn" and "anon" in source code. 2. There are not duplicate function name.
- Prefix function with fn_
- Anoymonus function parameter f?anX (? is the tail of function name like fn?, X is the uniq number)
- Variable name prefix by function abbreviation, if variable "a" inside function "fn_l" then renamed to "fl_a" if variable "b" inside annoymous function then renamed to "f?_anX_b"
Why not use auto-rename tools? function a() {var foo = "foo"} function b() {var foo = "bar"}
Generate the uniq function name and variable name: (seems like de-uglify) function a1cb13() {var _faxcb = "foo"} function fasdfz() {var abc2_3 = "bar"}
- So that when you rename variable, you are confident what you change and would not omit some replacements.