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

quote-type: single should (maybe?) allow double-quoted strings with escape sequences #609

Open
scolby33 opened this issue Nov 17, 2023 · 1 comment

Comments

@scolby33
Copy link

I use the below configuration, but came across the need to encode a string that contained a newline character, like so foo: "needs a newline\n". It's possible I'm missing something obvious, but should quote-type: single allow double-quoted strings that contain escapes? I realize that could mess people up in some cases, so maybe a new option should be added? If not, my solution for the moment is adding # yamllint disable-line rule:quoted-strings in the few places it turns out I need a newline.

quoted-strings:
  quote-type: 'single'
  required: true
@scolby33 scolby33 changed the title quote-type: single should allow double-quoted strings with escape sequences quote-type: single should (maybe?) allow double-quoted strings with escape sequences Nov 17, 2023
@adrienverge
Copy link
Owner

Hello Scott,

That's an interesting question.

I'm not sure what's best, but it's always possible to avoid double-quotes if one wants.
Here are 4 examples of writing the exact same value (needs a newline\n):

"needs a newline\n"
'needs a newline

'
>
  needs a newline
|
  needs a newline

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