Add a maximum allowed value for printWidth
See original GitHub issueI’ve just sent a PR to an open source project that uses Prettier, and here is their .prettierrc
:
module.exports = {
printWidth: 5000,
tabWidth: 4
};
I feel like this should not be allowed. I had a really long multi-line string with linebreaks. I had split it up into different strings using +
, and it looked fine. But then Prettier crammed it all onto one line that was over 300 characters long.
It would be nice if there was a sane hard-coded maximum for printWidth
. Maybe something like 130 characters for large high-resolution screens. I saw the issue about long “it” calls, and the limit shouldn’t apply for those cases.
I guess it’s true that if you give people an option, they’re going to do something crazy with it.
EDIT: I realized that some developers might turn on word-wrapping in their editor, so they have all the code on one line, but their editor breaks it up into multiple lines. IMO that’s the wrong way to do it, because Prettier was designed specifically for code-aware word wrapping. Why would you want to use your editor’s terrible word-wrapping, when you can have Prettier’s nicer formatting that indents everything properly?
And the other possibility is that there are some developers who prefer to scroll horizontally and view really long lines of code. That makes zero sense to me, but if you’re one of those developers, I’d love to hear from you!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:14 (7 by maintainers)
Top GitHub Comments
Can’t you ask the project maintainers to change their config to a more sane value? Or am I missing something?
Only if the person sets it to something above the limit we choose. And finding that limit will be really hard. So it doesn’t feel like this will work out in practice. Let’s see what responses we get over at https://github.com/sharegate/craco/issues/8 and re-open this if needed.