Reputation:
For example if we have this in a .ts file:
export const handleHMRMessages = (cache: any, store: CPReduxStore, conn: WebSocket) => {
conn.onclose = () => {
store.dispatch(actions.dev.hmrDisconnected());
};
}
prettier will remove all carriage returns above the first line of code in the func body:
export const handleHMRMessages = (cache: any, store: CPReduxStore, conn: WebSocket) => {
conn.onclose = () => {
store.dispatch(actions.dev.hmrDisconnected());
};
}
so I have been resorting to adding a comment above the declaration to preserve the space:
export const handleHMRMessages = (cache: any, store: CPReduxStore, conn: WebSocket) => {
// add comment here as needed
conn.onclose = () => {
store.dispatch(actions.dev.hmrDisconnected());
};
}
is there a prettier setting that can always have no more and no less space below a function declaration?
Upvotes: 6
Views: 3694
Reputation: 2678
No. Prettier is an opinionated formatter with limited configurability and is designed this way on purpose. The available options are listed here.
Upvotes: 2