Prettier 没有正确格式化空行
Prettier not formatting empty line properly
在我下面的 React Native 代码中,我希望 prettier 删除空行,但它没有。
screenOptions={{
headerTitleStyle: {
color: "#a41034",
fontWeight: "bold",
},
为什么会这样?
因为 Prettier 不会删除单数空行(通常)。
[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.)
此外,如果左大括号后有换行符,多行对象不会折叠成单行。
在我下面的 React Native 代码中,我希望 prettier 删除空行,但它没有。
screenOptions={{
headerTitleStyle: {
color: "#a41034",
fontWeight: "bold",
},
为什么会这样?
因为 Prettier 不会删除单数空行(通常)。
[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.)
此外,如果左大括号后有换行符,多行对象不会折叠成单行。