HookyQR / VSCodeBeautify

Enable js-beautify (https://github.com/beautify-web/js-beautify) in VS Code
MIT License
606 stars 180 forks source link

Breaks optional chaining (?.) and Nullish coalescing operator (??) #401

Open roflsunriz opened 3 years ago

roflsunriz commented 3 years ago

Provide the settings you use: nothing

Action performed

beautify JavaScript file

Expected results

beautify with optional chaining expression and Nullish coalescing operator held

option.f2 ? option?.f2(videoid, apiData) : false
var cacheIds = json[videoid].preferred ?? json[videoid].cacheIds[json[videoid].cacheIds.length - 1]

Actual results

optional chaining expression and Nullish coalescing operator broken (automatically adds spaces)

option.f2 ? option ? .f2(videoid, apiData) : false
var cacheIds = json[videoid].preferred ? ? json[videoid].cacheIds[json[videoid].cacheIds.length - 1]

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator

ExpertInvest commented 3 years ago

Hi, I'm experience the same issue. any solution? any updates?

SmileyChris commented 2 years ago

Update the bundled version of js-beautifer: #346 (then restart VScode)