6

I'm trying to get Prettier to format my files with a printWidth of 80 chars (what I understand to be the default). However, even with my user settings configured:

"prettier.printWidth": 80

AND using a .prettierrc config in the project:

{
  "tabWidth": 2,
  "useTabs": false,
  "printWidth": 80
}

...nothing changes when I save a file (other settings are implemented, which makes me think there is a conflict somewhere).

Even the Prettier output in VS Code shows that it's pulling in the config:

["INFO" - 8:27:53 PM] Using config file at '/Users/username/Documents/whatever/.prettierrc'
["INFO" - 8:27:53 PM] Prettier Options:
{
  "filepath": "/Users/username/Documents/whatever/project/file.mdx",
  "parser": "mdx",
  "tabWidth": 2,
  "useTabs": false,
  "printWidth": 80
}
["INFO" - 8:27:53 PM] Formatting completed in 93.855083ms.
Rob Lauer
  • 3,075
  • 1
  • 32
  • 44

1 Answers1

8

You're formatting MDX, which is a variant of Markdown. Breaking text to respect the print width in Markdown is considered unsafe by default because this can affect some renderers sensitive to line breaks. That's why Prettier's option proseWrap(docs) defaults to preserve. Set it to always for Prettier to start wrapping text.

thorn0
  • 9,362
  • 3
  • 68
  • 96