Looking for a way in a .prettierrc file to prevent line space removal before an anonymous function, example before save:
export const a = file => {}
export const b = file => {}
;(async () => {
console.log('foobar')
})()
and after save:
export const a = file => {}
export const b = file => {}
;(async () => {
console.log('foobar')
})()
In a .prettierrc file, how can I prevent the line removal before an anonymous function?
I'm pretty late, but essentially you can't. Prettier is an opinionated formatter , which means you won't be able to have the level of customization you're looking for in this situation.
You could try using EditorConfig or ESLint , which even though it's a linter (and not a formatter), it can be used as such.
That being said, I wouldn't worry about this too much. The aim of formatters should be to keep a code style consistent, especially when collaborating with other developers. That's why most popular formatters are opinionated. No one wants to be in a team having meaningless discussions about code style :).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.