adrienverge / yamllint

A linter for YAML files.
GNU General Public License v3.0
2.83k stars 269 forks source link

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

Open scolby33 opened 9 months ago

scolby33 commented 9 months ago

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
adrienverge commented 9 months ago

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