-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File-level page width configuration #1157
Comments
Some configuration prior art are the analyzer ignore_for_file directives:
and the dart language directive:
|
Phew. This is a thing we could do. But given how incredibly heated discussions of line length get, I worry that if we do this, everyone will start configuring the line lengths of all of their files. And then when you're bouncing between Dart files in different packages, it will get much harder to decide how to configure the window size in your IDE. |
Isn't being able to make sense of code more important than having to deal with resizing windows? Sure, it'd be pretty impossible to make sure every potential piece of code is formatted optimally for readability. So dart format has to do a best effort, which for most cases is wonderful. It is subjective whether 80 vs 100 vs 120 character lines for a particular file is most readable and people will have their own opinions. However, like @devoncarew, I've found that especially for generated files 80 characters is just too little. I know some people have similar feelings about files with lots of flutter widgets with their build methods with lots of nested widgets. |
I would personally prefer to see #918 implemented, which I think would solve this (just put your generated files in a package that configure the line length for all of them to 120). |
@dnfield it would be useful for files defining configs or constants where you often see maps with entries having different length. In this case, having one entry per line is better for readability, meanwhile increasing the line length for the whole package is not worth considering. |
This is a feature request to support the ability to configure the formatting line length from within the target file.
The use case here is that I have a project that's generating very large dart source files; they're generated from wasm files and replicate the operations specified in those files. Roughly, each generated source line corresponds to a wasm instruction. This works well (is readable) except in cases where there's significant nested control flow. In those cases, the indent pushes the contents past the 80-char boundary, and the generated operations start re-flowing into new lines (generally not doing good things for the readability).
To address this I'm experimenting with formatting the files - as the last step of codegen - with a longer line length; ~100 - ~120 chars. That generally works even for the most nested files. However, there are two issues:
dart format --output=none --set-exit-if-changed
as part of a CI, it'll fail on these filesThe feature request is for a way to configure the line length that a file should be formatted at from within the file itself. So, something like:
The text was updated successfully, but these errors were encountered: