question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a maximum allowed value for printWidth

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
lydellcommented, Nov 12, 2018

Can’t you ask the project maintainers to change their config to a more sane value? Or am I missing something?

2reactions
lydellcommented, Nov 12, 2018

That’s another reason for setting some sane limits for the options, because it will prevent this kind of misunderstanding.

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Options - Prettier
max -len just says what the maximum allowed line length is, but not what the generally preferred length is – which is what...
Read more >
ESLint / Prettier -- enforce max-len / printWidth, but don't ...
Set print-width to 999 in prettier to turn it off, then set the eslint max-len rule to be a warning at what ever...
Read more >
Visual Studio Code and Prettier not respecting print width field
After some research it was suggested to change the Prettier:Print Width property from the default value or 80 to 120, which I've done....
Read more >
std::fmt - Rust
Each formatting argument is allowed to specify which value argument it's referencing, and if omitted it is assumed to be “the next argument”....
Read more >
FSXUOLIPI M110 Label Maker - Max Print Width 1⅞ ...
Buy FSXUOLIPI M110 Label Maker - Max Print Width 1⅞'', Bluetooth Portable Thermal Label Printer for Product, Barcode, QR Code, Address, for iOS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found