简体   繁体   中英

Prettier not formatting empty line properly

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?

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM