I just started using the PrettierJS Plugin for VSCode and I am looking for a way to preserve my code format of my service calls (and subsequent Promises).
I know you can add the //prettier-ignore
ments just before the code block to preserve the code pattern, but since i do this all over my app, i do not want to add that ment-line everywhere.
Right now, my code block looks like this:
return this.thingService.addThing(newThing)
.then(wonFunction)
.catch(lostFunction);
But when i do the Prettier format mand i get this:
return this.accessData.addRight(newRight).then(wonAddAccessRight).catch(lostAddAccessRight);
I want a way to preserve my code blocks from changing without using the //prettier-ignore
ments.
I just started using the PrettierJS Plugin for VSCode and I am looking for a way to preserve my code format of my service calls (and subsequent Promises).
I know you can add the //prettier-ignore
ments just before the code block to preserve the code pattern, but since i do this all over my app, i do not want to add that ment-line everywhere.
Right now, my code block looks like this:
return this.thingService.addThing(newThing)
.then(wonFunction)
.catch(lostFunction);
But when i do the Prettier format mand i get this:
return this.accessData.addRight(newRight).then(wonAddAccessRight).catch(lostAddAccessRight);
I want a way to preserve my code blocks from changing without using the //prettier-ignore
ments.
1 Answer
Reset to default 8Prettier now automatically breaks a chain of 3 or more functions in separate lines (current version as I'm writing is 1.9.1), so the formatting is a bit different from what OP requested:
return this.accessData
.addRight(newRight)
.then(wonAddAccessRight)
.catch(lostAddAccessRight);
But if you wanted to force it to break if you have only 2 functions, there's a hack that is to add a ment and Prettier will automatically break it:
return promise // force break
.then(didResolve)
.catch(didReject);