1. Line length is configurable
2. Spaces have no advantages (alignment doesn't work with dartfmt)
option).
Post by 'Bob Nystrom' via Dart MiscI really need a FAQ entry for this since it comes up often.
Configuring indentation is an entirely reasonable request for some kinds
of formatters, but not for dartfmt. The priorities for dartfmt are *in
descending order:*
1.
Produce consistently formatted code. Consistent style improves
readability because you aren't distracted by differences in style between
different parts of a program. It makes it easier to contribute to others'
code because their style will already be familiar to you.
2.
End debates about style issues in code reviews. This consumes an
astonishingly large quantity of very valuable engineering energy. Style
debates are time-consuming, upset people, and rarely change anyone's mind.
They make code reviews take longer and be more acrimonious.
3.
Free users from having to think about and apply formatting. When
writing code, you don't have to try to figure out the best way to split a
line and then painstakingly add in the line breaks. When you do a global
refactor that changes the length of some identifier, you don't have to go
back and rewrap all of the lines. When you're in the zone, you can just
pump out code and let the formatter tidy it up for you as you go.
4.
Produce beautiful, readable output that helps users understand the
code. We could solve all of the above goals with a formatter that
just removed *all* whitespace, but that wouldn't be very
human-friendly. So, finally, the formatter tries very hard to produce
output that is not just consistent but readable to a human. It tries to use
indentation and line breaks to highlight the structure and organization of
the code.
Configurability goes directly against the first two priorities, and
halfway against the third (you have to think about it, but not apply it).
This may be surprising, but the goal of dartfmt is *not* to
automatically make your code look the way you like. It's to make
*everyone's* Dart code look *the same*. The primary goal of dartfmt is
to improve the quality of the Dart *ecosystem*. That transitively
improves the live's of each Dart developer as wellâyou get more code to
reuse, more consistent code, it's easier to read and contribute to each
other's code, etc. But it does that at the expense of individual preference.
It requires you to buy in to the idea that a consistent ecosystem is more
valuable than anyone's individual formatting preferences. Or, another way
to say that is that no one's individual formatting style is measurably
better enough than what dartfmt produces to compensate for the costs of
inconsistency.
If you don't buy that, that's OK. It just means dartfmt probably isn't
the right tool for you.
Cheers!
â bob
Post by Danny TuppenyAVOID lines longer than 80 characters.
DONâT use tabs.
I hope whoever made this decision feels really bad about it now! ;(
Post by Danny TuppenyI've been really trying, but the whole two space thing really bugs me ;(
I don't expect it will happen, but it seems (to me) a reasonable
request, so I thought I'd ask!
https://github.com/dart-lang/dart_style/issues/534
We can configure line length already, so it's not like we're guaranteed
consistency. This just allows users to have some more control over how
their code looks without totally having to give up dartfmt!
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
"Dart Misc" group.