-
Notifications
You must be signed in to change notification settings - Fork 125
Change string literals to use ' consistently (WONTFIX) #451
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
Comments
I would love to have this be enforced in some tool somewhere, but it's outside of the formatter's core charter. It only touches non-semantic whitespace. This avoids a lot of ratholes and, in particular, helps ensure the formatter's behavior is reversible. Consider this user path:
The code at 5 should be the same as at 1. That's hard to guarantee if the formatter makes non-whitespace changes. (Though, in this specific case, I think it would be OK. But I think it's important for the formatter to have a simple charter and "only whitespace" is a good one.) |
I don't understand why "non-semantic whitespace" is ok to touch, and "non-semantic punctuation" is not. The steps you describe would work just the same with the feature requested in this issue. Start with formatted code (i.e. using I would argue that whitespace is a lot more "semantic" than quotation marks. The analyzer right now destroys well-aligned code in a non-reversible way, which is a much bigger deal than whether or not it forgets which types of quotation marks were originally used. :-) |
Touching anything other than whitespace opens up a can of worms. Things like:
I think many of these are tractable, but they get fuzzy and the list of them is near infinitely wrong. That's great for a linter where a human can validate, customize, and tweak the output. It's not a good fit for a formatter that's designed to be run automatically on presubmit scripts over all user code. |
I mean, I can tell you simple answers for all these for the Flutter style. I don't see why they'd be any more intractable than whitespace issues. At the end of the day, they're part of the formatting rules that the project has to follow. Right now we use code review and post-hoc cleanup to make the code consistent; the more of that we can defer to a tool the better, IMHO. If the tool only does whitespace cleanup, then that just means we keep having to do some of the cleanup manually. |
One of the things that we originally left open in the Flutter style guide, but later narrowed down by popular demand, was string literal quotation. We now require that you use
'
for literals and"
for nested strings (as in,'Hello ${name ?? "user"}!'
).Any chance we could have the formatter enforce that?
The text was updated successfully, but these errors were encountered: