beautifier / js-beautify

Beautifier for javascript
https://beautifier.io
MIT License
8.63k stars 1.39k forks source link

Does this currently support babel/es2015/es6? #780

Open michaelBenin opened 9 years ago

michaelBenin commented 9 years ago

I think it would be helpful if the readme contained support.

prettydiff commented 9 years ago

As far as I am aware js-beautify supports a good deal of ES6, though it is challenging to say how much. The only way to gauge the degree of support is to examine a large variety of unit tests and determine the percentage passing and identify any defects.

It would be silly for any project to claim 100% support when even the browsers and babel don't offer 100% support.

bitwiseman commented 9 years ago

@prettydiff - well said. :+1:

@michaelBenin - I do see your point. This project has come a long way (and also has a long way to go). Javascript is is used in many different environments and dialects (ES6, ES7, Dart, ReactJS). It would be helpful to have a high-level view of what is supported and what isn't. That said, nailing down the degree of support for various dialects is time consuming.

This best path at this point is to try it, see if any issues you encounter have already been filed, and if not, please file them.

bitwiseman commented 8 years ago

If anyone would like to suggest how to measure es6 support, I'm open to it.

prettydiff commented 8 years ago

Perhaps if there were a directory in the unit tests specifically for ES6 cases. The more unit tests there the better, and not for identifying current ES6 support, but for identifying missing support. This would provide direction on what is missing and potential defects. It would require contributions from the community to increase the quantity and diversity of tests.

prettydiff commented 8 years ago

To get this started I use these files to test destructuring, which is a concept new to ES6. The files also contain a lot of code examples with minor ES6 conventions:

I process the code from the raw directory and compare to the sanitized code in the correct directory as a part of my unit tests.