-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
TL;DR: Should max_line_length=off
in .editorconfig
get interpreted as printWidth: Number.MAX_SAFE_INTEGER
, or should we continue ignoring it, or something else?
Hey everyone, I'm the maintainer of editorconfig-to-prettier, which Prettier uses to convert EditorConfig configuration to Prettier configuration.
Over 5 years ago, bug #3410 was reported regarding the handling of max_line_length=off
, and resulted in @duailibe fixing editorconfig-to-prettier
to ignore max_line_length=off
in .editorconfig
files (the corresponding dependency version bump can be found here).
However, there's been some renewed interest from @celluj34 in having Prettier interpret max_line_length=off
to mean e.g. printWidth: A_REALLY_BIG_NUMBER
like Number.MAX_SAFE_INTEGER.
My question is, would this cause unintended consequences? For example, would Prettier attempt to generate very long lines for files where max_line_length=off
? I see that https://prettier.io/docs/en/options.html#print-width says:
In other words, don’t try to use printWidth as if it was ESLint’s max-len – they’re not the same. max-len just says what the maximum allowed line length is, but not what the generally preferred length is – which is what printWidth specifies.
but I wonder if it would be ok in practice. I took a quick look at the playground with --print-width
set to 9999, and the output seems reasonable-ish:
function HelloWorld({ greeting = "hello", greeted = '"World"', silent = false, onMouseOver }) {
if (!greeting) {
return null;
}
// TODO: Don't use random in render
let num = Math.floor(Math.random() * 1e7)
.toString()
.replace(/\.\d+/gi, "");
return (
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>
<strong>{greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase()}</strong>
{greeting.endsWith(",") ? " " : <span style={{ color: "grey" }}>", "</span>}
<em>{greeted}</em>
{silent ? "." : "!"}
</div>
);
}
Part of me thinks that if someone is explicitly putting max_line_length=off
in their .editorconfig
, then they should be ok with this formatting. On the other hand, I haven't really used Prettier for a while now, and I'm not very familiar with the variety of use cases people have for it, so I thought I'd ask here.
What do you think? Should max_line_length=off
in .editorconfig
get interpreted as printWidth: Number.MAX_SAFE_INTEGER
, or should we continue ignoring it, or something else?
Thanks!