Is there a way to disable the printWidth rule warning in prettier?
I want to be able to determine my own line length for readability. In certain cases I want a line break, and in other cases I don't.
I tried this in my .prettierrc file :
{
"singleQuote": true,
"printWidth" : "off"
}
But this does not work.
prettier-vscode", If you want to disable Prettier for a specific language, you can set the editor. defaultFormatter to null .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With