fauxton edit view format code button breaks es6 arrow functions
ericlowry opened this issue · comments
Description
CouchDB 3.0 allows writing es6 arrow function closures, so instead of writing your map function like this:
function(doc) { if (doc.type === 'WIDGET' ) emit(doc.code,1); }
you can now do this:
doc => doc.type === 'WIDGET' && emit(doc.code,1)
or even this:
({type,code}) => type === 'WIDGET' && emit(code,1)
Works perfectly in CouchDB, returns the proper results in the view...
But if you press the Format Code
button in Fauxton, it breaks breaks the code, by injecting spaces between into the arrow function :-(
Steps to Reproduce
- create a view and write a map function using an arrow function similar to the ones above.
- Save and test the view to see the arrow functions working
3 edit you view and click the format code button, watch as it corrupts your beautiful view into something unrecognizable to couchdb...
Expected Behaviour
should format the code with an understanding of modern javascript, like prettier does ;-)
Your Environment
- CouchDB version used: 3.0
- Browser name and version: Chrome
- Operating system and version: Docker, latest CouchDB container
Additional Context
I consider this a Bug and not a feature request because it breaks the code. If I didn't like the formatting or something, than I would consider this a feature change...
Fixed on master