jscodeshift icon indicating copy to clipboard operation
jscodeshift copied to clipboard

Scope issues with Rename

Open analtevs opened this issue 2 years ago • 0 comments

this example comes from some obfuscated code

function Os(n){
...
}
...
const i = function t() {
  var e = Os;
  new MutationObserver((t=>{
    var r = e; 
    for (const e of t) {
      if (e[r(1849)] !== r(1336)) continue;
      for (const t of e['addedNodes']) if (t['tagName'] === r(416) && 'modulepreload' === t['rel']) i(t)
    }
  })) [e(2593)](document, {childList: !![], subtree: !![]});
}

when renaming e = Os i expected r to be renamed. the const e is getting in the way of this with regards to scope.

posted an example on astexplorer here

if cosnt e is manually renamed then i do get the expected results (r = Os)

analtevs avatar Sep 07 '22 04:09 analtevs