Reputation: 514
In my React Native code below, I'm expecting prettier to remove the empty line but it doesn't.
screenOptions={{
headerTitleStyle: {
color: "#a41034",
fontWeight: "bold",
},
Why is that so?
Upvotes: 9
Views: 29528
Reputation: 2892
also in your VSC, click on file -> preferences -> settings -> type: format default, there will be an option: Editor Default Fromatter (drop down), set this to Prettier
its just that some files like JSX/TSX need you to assign them a default formatter, otherwise they will use something like TypeScript formatter, and it will retain blank spaces.
Upvotes: 0
Reputation: 160191
Because Prettier doesn't remove singular blank lines (in general).
From the "empty lines" docs:
[Prettier preserves] empty lines the way they were in the original source code. There are two additional rules:
- Prettier collapses multiple blank lines into a single blank line.
- Empty lines at the start and end of blocks (and whole files) are removed. (Files always end with a single newline, though.)
Additionally, multi-line objects are not collapsed into single-lines if there's a newline after the opening curly brace.
Upvotes: 7