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

quotes=preferSingle/preferDouble behave more like forceSingle/forceDouble #3

Closed
jakebailey opened this issue Aug 22, 2024 · 4 comments

Comments

@jakebailey
Copy link

I have YAML like:

some_string: "This isn't working"

If I set quotes=preferSingle, the formatter outputs:

some_string: 'This isn''t working'

Even though the docs say that the opposite quote style is used to avoid extra escapes:

"preferDouble" - Use double quotes as possible. However if there're escaped characters in strings, quotes will be kept as-is. (Recommended) (Default)
"preferSingle" - Use single quotes as possible. However if there're \ char or " char in strings, quotes will be kept as-is.

Current behavior: https://dprint.dev/playground/#code/G4QwNgrgpgXABAcgBJTGA9gQgQWAFD6iRQBM8ARACoAWAlgM5wMB2CALnCHALZT30gA5lAB05IA/config/N4WAUABBBEAOBOBLAdgFwOqICaoBbQC4IAOABgBpwpoBXAZwFMAVAQwCM7CIAzFgG0aVIMFFgZpMOfEQBMQ6nxQMAQvAYsA1l2h9u0eTACONAPaoGnInDXcG8AMooA5nwb6qMVPBaJFyJwDCJgC2wSxcXjQMBtDcJvBhqEGh4qiWPPyCHtCiqcp8JgDGGvYMxuKFDACSyACyLLAR8FExbN6V9rAshc5NLdlt3RoMqJ3dvUS8AtHZXojBTN6+zui4iOZ0XZXpkTPC0HMLS35OAFp2JlxTWfuITsjxDMnBqQAiiGqFqIgAbm5WCBGqAAngBaYEsYJ8UF3B5qaDgAC+4CAA/plugin/pretty_yaml

What I would expect (e.g. prettierish): https://prettier.io/playground/#N4Igxg9gdgLgprEAuEA3AhgGwK5yQAgHIAJOTTCAQkIB0o6Mc4AmAmkAFQAsBLAZ3z8ohGPnT4AtnD590AczgA6diAA0ICAAcYPaH2Sh0AJyMQA7gAVjCfSixn0AT33qARkfRgA1nBgBldCkAGR4oOGQAMyw+ODcPb18-TU9QuWQYI1x1GIkedMzYkDgAD004Ix4pWCwOcqhjHmlI6MK+VMw4AEVsCHh8rJAAKz5iv3aunr6kKMwY9QBHSbgLU01bEHQ+AFowuAATfbUQDPQeTFSAYQgJCXRkDfIjtqg5DoBBGAyeV2x4C3KQmFmrNClwYBJMAB1XjwPjJMBwPw2Hg6VAoxz3MAyI6oXAASSgB1gfjAFW0b0Jfhgjg6wLmIE0phikI8mnujOk5VQ4XUoRiRhgK3ktzphWSRn590cgUwR0ZoRgkJ4exgXGQAA4AAzqIxwRY8XVCuQi6YtdQwdCuJUqtVIZjqbAxDiW2wzelwCSufYHPZBdAvbDyOAAMQgRlun1S93QvwgIAAvvGgA

A code example: microsoft/TypeScript@main...jakebailey:TypeScript:pretty-yaml

@g-plane
Copy link
Owner

g-plane commented Aug 23, 2024

Sounds reasonable. I'm going to change the behavior of preferSingle/preferDouble and add alwaysSingle/alwaysDouble options, but the default option value will still be preferDouble.

@jakebailey
Copy link
Author

Thanks! Yes, "always" is probably the right term.

@g-plane
Copy link
Owner

g-plane commented Aug 25, 2024

Released v0.5.0.

@jakebailey
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants