Skip to content
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

Configuration for quote style of strings #28

Closed
JohnnyMorganz opened this issue Jan 14, 2021 · 3 comments · Fixed by #73
Closed

Configuration for quote style of strings #28

JohnnyMorganz opened this issue Jan 14, 2021 · 3 comments · Fixed by #73
Labels
rfc/in discussion This issue is currently in discussion, comments are welcome!

Comments

@JohnnyMorganz
Copy link
Owner

Quote style (single quote vs double quote) for strings is a hot topic, including what to do with escapes, consistency etc.
I was wondering whether we should introduce configuration for this specific point.

There would have to be two parts to this:

  1. quote style (single quote or double quote), and
  2. forcing quote style - should we force the chosen quotes regardless of whether we could reduce the number of escapes in the string or not? There are arguments for this (consistency with all strings in codebase) and against (reduce number of escapes necessary, making string easier to read).

So, there are two questions to answer here: 1) should we add this configuration option? and 2) what should be our default? [currently our default is double quote - which will remain so - and forcing regardless of escapes - which I'm not sure which is better]

@JohnnyMorganz JohnnyMorganz added the rfc/in discussion This issue is currently in discussion, comments are welcome! label Jan 14, 2021
@Dekkonot
Copy link

I'm in favor of adding a configuration and I think forcing it is good.

I can't see it being desirable to swap out string styles to avoid as many string escapes as possible. That seems to go in the face of "consistency" and is really only applicable to \" and \', neither of which are particularly common -- it's been quite a while since I've used "\"" for anything outside of side projects.

@LastTalon
Copy link
Contributor

I tend to agree with prettier's string rationale. The whole point of using a formatter is that the computer can make these changes when people are unable/unwilling and do it correctly every time. So I'd rather the formatter aim to reduce the amount of escaping in the string as much as possible.

I'll agree with how they do prettier's option as well here. And I think the option for configuration is a good idea in this case.

@JohnnyMorganz
Copy link
Owner Author

#73 will add support for this configuration. I have decided to default to preferring double quotes, but not forcing it. I did this so it falls in line with other similar formatters, like prettier. The original behaviour is still available by setting quote_style = "ForceDouble" in a config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfc/in discussion This issue is currently in discussion, comments are welcome!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants