disable printWidth on prettier

The short answer is no, you cannot disable it entirely.

There are, however, a few workarounds, but they have caveats.

To quote an answer from this issue on github: https://github.com/prettier/prettier/issues/3468.
printWidth is not a rule but an input into the algorithm they use to generate their output. Meaning, it is required to be there.

One workaround is to set printWidth to a really high number, but although this will prevent lines from breaking, changing this property will affect your entire codebase, causing other lines throughout it to combine into a single line, which is most likely not desired.

Your second option is to disable prettier for a block of code with the // prettier-ignore syntax. The downside to this is that you’ll disable all prettier features for this section of the code. Also, I personally don’t find it very “clean” to have comments like that all over your code.
You can read about how to use the ignore functionality here: https://prettier.io/docs/en/ignore.html

Leave a Comment