Add support for unifying quote style (single- vs. double-quotes) of string literals
When pasting code from documentation, tutorials, stackoverflow, etc. I often have to manually unify the quote style (single-quotes vs. double-quotes) of string literals. It would be super cool if js-beautify had an option for that.
This is the sort of thing that needs parsed AST (#200), which is unfortunately hard to do with our current algorithm (not to mention Python and JS platform requirements). In the meantime, esprima (via escodegen) demonstrates one way to do this particular kind of transform.
is there any progress with this?
No, there is not progress on this and there is unlikely to be any for sometime. The beautifier is designed to modify only the whitespace of javascript input. This scenario is one that we specifically avoid at this time due to the limitations mentioned above. Also as noted above, there are other projects that might serve you better in this scenario.
We're leaving this open as a possible future enhancement along with other code folding feature requests.
+1 :+1:
I was able to make some changes to the javascript version to change single quotes to double quotes (or vice versa). It might not work in all cases. See https://gist.github.com/nmalaguti/576d191c4547cdf7e0cb lines 18-21 and 114-119 for the code changes.
@bitwiseman I understand that Javascript requires something like #200, but what about HTML support or CSS? Any hope of them being tackled separately (and sooner? 😁)