3 ms·
It unfortunately can't do it in that direction, at least yet. It would be quite difficult in the general case to keep JavaScript formatted the same after it's
by an_ko 6y ago
It unfortunately can't do it in that direction, at least yet.
It would be quite difficult in the general case to keep JavaScript formatted the same after it's been munged into S-expressions and converted back again. It would work the same, just look different. And the comments would disappear!
However, there has been some work into making a spec for a JS Concrete Syntax Tree (as opposed to Abstract Syntax Tree) which would retain whitespace, comments, and other such concrete "junk" that an AST typically abstracts out. https://github.com/estree/estree/issues/41; https://github.com/estree/estree/issues/41; https://github.com/cst/cst https://github.com/cst/cst It would be super cool to turn up at work in a JS shop armed with Emacs, and writing JavaScript at lightning speed using macros and structural editing, without anyone noticing.
It's a good idea. I'll make a note of it.