About an year ago, when it became clear that sooner or later I'll have to write ES6 code, I decided to give js2-mode another look (wow, how time flies!)
Steve Yegge no longer seems to maintain this majestic creation, but as it often happens in the open-source world, quality code finds new home and maintainers. The official fork today is located at https://github.com/mooz/js2-mode, and it's what you get if you install it from Melpa. However, I live on my own fork where I fix bugs as I find them. Eventually, my fixes get merged into the official repo.
On top of js2-mode
, Magnar Sveen of emacsrocks.com fame wrote js2-refactor, a collection of tools for working on JavaScript
code. It brings new powers at your fingertips — for example, you can select a piece of code and turn it into a
function; it figures out what are the variables needed by that piece of code, and turns them into arguments of the new
function; and replaces that piece of code with a call to the new function, which is inserted just outside the current
function. All that happens in a split second — an operation that would take many seconds to do manually. If you edit
JavaScript, and use Emacs, make sure to check js2-refactor
.
Before switching to js2-mode
+ js2-refactor
, I had some utilities for editing JS that worked with an external parser (based
on UglifyJS). I have ported these tools on top of js2-mode
and js2-refactor
, so we don't need
to call an external parser, and we get support for ES6. I wanted to briefly cover it in this post, and perhaps if more
people are interested I will submit a pull request to js2-refactor
.
[ read more... ]