These are experimental babel transforms for cleaning up your codebase with nice ES6+ idioms.
Babel is usually used for turning nice source code into runnable source code. But in this case we can take advantage of its infrastructure to do the reverse: take an old codebase and make it nicer.
For example, we can turn CoffeeScript into ES6 by first compilng it with our usual coffescript compiler, and then running it through these transforms to opportunistically clean up the resulting messes.
Using them
These are still experimental, good luck.
- npm install -g
Transformations
Fat-Arrowize
This transform looks for opportunities to rewrite functions as arrow
expressions, based on the use of this
. Function expressions that
don't access this
are safe to rewrite, so:
myList
becomes:
myList
We can also detect common patterns for binding this
and greatly
simplify them. For example, this is how CoffeeScript's fat arrow
compiles:
myList;
which we can automatically convert to:
myList;