'Is it possible to stop prettier from adding an extra tab for .then() {} statements after Promise.try?
So, I was wondering if it is possible to stop prettier from adding an extra tab for .then() {}
statements after Promise.try
or just simple return PromiseFn() .then(() => {})..
Usually, I write promise chains, that look something like this:
import Promise from "Bluebird"
Promise.try() {
// code..
})
.then(() => {
// more core
})
.then(() => {
// more code
})
How prettier makes it look like:
Promise.try() {
// code..
})
.then(() => {
// more core
})
.then(() => {
// more code
})
So I was wondering, if it is possible to stop prettier from adding the extra, non-needed tab before all the .then()
statements?
Solution 1:[1]
It seems Prettier is a very opinionated formatter...
But you may be able to flag to Prettier to ignore the next node
// prettier-ignore
Promise.try() {
// code..
})
.then(() => {
// more core
})
.then(() => {
// more code
})
We dropped using Prettier in our project for this reason, it didn't allow for formatting how we wanted to. And TBH I'm not even sure the above will still work for what you want, but it seems the best option to try.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Drew Reese |