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.
These are still experimental, good luck.
- npm install -g
This transform looks for opportunities to rewrite functions as arrow
expressions, based on the use of
this. Function expressions that
this are safe to rewrite, so:
We can also detect common patterns for binding
this and greatly
simplify them. For example, this is how CoffeeScript's fat arrow
which we can automatically convert to: