Skip to content

Unstable template literals marked with /* HTML */ and /* GraphQL */ #6150

@thorn0

Description

@thorn0

Happens if the template literal initially doesn't contain line breaks.

Another issue about unstable template literals: #5885

HTML in JS

Prettier 1.17.1
Playground link

--parser babylon

Input:

foo(/* HTML */ `<!-- bar1 --> bar <!-- bar2 -->`);

Output:

foo(
  /* HTML */ `
    <!-- bar1 -->
    bar
    <!-- bar2 -->
  `
);

Second Output:

foo(/* HTML */ `
  <!-- bar1 -->
  bar
  <!-- bar2 -->
`);

GraphQL in JS

Prettier 1.17.1
Playground link

--parser babylon

Input:

foo(/* GraphQL */ `query { foo { bar } }`);

Output:

foo(
  /* GraphQL */ `
    query {
      foo {
        bar
      }
    }
  `
);

Second Output:

foo(/* GraphQL */ `
  query {
    foo {
      bar
    }
  }
`);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions