prettier: Tagged template strings shouldn't be on a new line

I’m an ember user, which uses tagged template strings for component testing. Normally, you’d write something that looks like:

this.render(hbs`
  <p>Some stuff here</p>
  {{some-handlebars-stuff}}
`);

For some reason, Prettier instead turns this into:

this.render(
  hbs`
  <p>Some stuff here</p>
  {{some-handlebars-stuff}}
`
);

It doesn’t seem like this should be necessary based on line length… is there something I’m missing? Or is this an error on Prettier’s end?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 15 (6 by maintainers)

Most upvoted comments

@bakkot I’d like ` `'s behaviour to be consistent with (), {} and []. For example:

  const res = graphql(shortArg)
  const res = graphql({ shortArg })
  const res = graphql(`shortArg`)

  const res = graphql(
    veryveryveryveryveryveryveryveryveryveryveryveryveryveryvery_long_arg,
  );
  const res = graphql({
    veryveryveryveryveryveryveryveryveryveryveryveryveryveryvery_long_arg,
  });
  const res = graphql(`
    veryveryveryveryveryveryveryveryveryveryveryveryveryveryvery_long_arg,
  `);

  const res = graphql(
    { manyargs1 },
    manyargs2,
    manyargs3,
    manyargs4,
  );
  const res = graphql(
    `manyargs1`,
    manyargs2,
    manyargs3,
    manyargs4,
  );

  const res = graphql(
    {
      manyargs1,
      manyargs2,
      manyargs3,
      manyargs4,
    },
    manyargs2,
    manyargs3,
    manyargs4
  );
  const res = graphql(
    `
      manyargs1,
      manyargs2,
      manyargs3,
      manyargs4,
    `,
    manyargs2,
    manyargs3,
    manyargs4
  );

What do you think?

Both the first two examples now remain as is

this.render(hbs`
  <p>Some stuff here</p>
  {{some-handlebars-stuff}}
`);

<Dropdown.Item selectable={false}>
  {m`
    No results for {value}
    ${{ value: <em>{value}</em> }}
  `}
</Dropdown.Item>;

I’m going to close this issue as it’s mostly solved.