With Crockford's JSLINT, after calling JSLINT()
to parse some JavaScript source, it provides access to the parse tree via JSLINT.tree
It would be really powerful to be able to analyse the tree, make structural changes to it based on the analysis and then generate new JavaScript from the modified tree.
Is there an open source project that builds on JSLINT by providing a conversion from a parse tree back to JavaScript?
(Is this even possible, i.e. does JSLINT keep complete enough information from the parse to round-trip everything significant?)
I dont know if JSLint can do it (looking at some of the forum postings, it doesnt look like maintaining the tree is their goal but its a by-product for doing the linting process).
The uglifyjs project may help with generating an AST from javascript and re-converting a AST to code. See this method for AST to javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With