5to6 / 5to6-codemod

A collection of codemods that allow you to transform your js code from ES5 to ES6.
https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb
301 stars 40 forks source link

Convert anonymous functions to arrow #12

Open xjamundx opened 8 years ago

xjamundx commented 8 years ago

Anytime we have an anonymous function we can convert to an arrow function

hello(function () {

});

// becomes
hello(() => {

})
nickmccurdy commented 7 years ago

This would be cool, but careful about the differences in scope with this and arguments. It might be enough to only run this on functions that don't use either keyword, though if someone uses this you can't be 100% sure if they're using a this in another scope or if a scope is bound to the anonymous function.