Skip to content

Support quoteProps in YAML #16037

Open
Open

Description

@abemedia

Strings in YAML do not need to be quoted if they don't contain special characters (or numbers which should be parsed as strings).
Prettier already has support for the same thing in JSX using the quoteProps option, it would be great to also have this in YAML!

Activity

  1. garysassano commented on Apr 30, 2024

    @garysassano

    I'm also requesting this. I want to follow YAML 1.2.2 specification, which recommends the following:

    • Whenever applicable use the unquoted style since it is the most readable.
    • Use the single-quoted style (') if characters such as " and \ are being used inside the string to avoid escaping them and therefore improve readability.
    • Use the double-quoted style (") when the first two options aren't sufficient, i.e. in scenarios where more complex line breaks are required or non-printable characters are needed.

    My current configuration in VS Code:

    "[yaml]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
      "editor.formatOnSave": true,
      "editor.tabSize": 2,
      "prettier.singleQuote": true,
      "prettier.quoteProps": "as-needed",
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions