Skip to content

[Bug] 2.0.0 Errors when components contain multi-byte characters (e.g. emoji) 💩 (not always, though) #191

@NullVoxPopuli

Description

@NullVoxPopuli

🐞 Describe the Bug

I recieved a syntax error, even though I was not expecting one.

🔬 Minimal Reproduction

the file

import Component from '@glimmer/component';
import { on } from '@ember/modifier';

import { getSnippetElement, toClipboard, withExtraStyles } from './copy-utils';
import Menu from './menu';

/**
 * This component is injected via the markdown rendering
 */
export default class CopyMenu extends Component {
  copyAsText = (event: Event) => {
    let code = getSnippetElement(event);

    navigator.clipboard.writeText(code.innerText);
  };

  copyAsImage = async (event: Event) => {
    let code = getSnippetElement(event);

    await withExtraStyles(code, () => toClipboard(code));
  };

  <template>
    <Menu data-test-copy-menu>
      <:trigger as |t|>
        <t.Default class="absolute top-3 right-4 z-10" data-test-copy-menu>
          📋
        </t.Default>
      </:trigger>

      <:options as |Item|>
        <Item {{on "click" this.copyAsText}}>
          Copy as text
        </Item>
        <Item {{on "click" this.copyAsImage}}>
          Copy as image
        </Item>
      </:options>
    </Menu>
  </template>
}

😕 Actual Behavior

the error:

app/components/limber/copy-menu.gts
[error] app/components/limber/copy-menu.gts: SyntaxError: Unexpected token (41:1)
[error]   39 |     </Menu>
[error]   40 |   </template>
[error] > 41 | }
[error]      | ^
[error]   42 |

🤔 Expected Behavior

no error

🌍 Environment

  • prettier-plugin-ember-template-tag version: - 2.0.0-0
  • ember-template-imports version (if applicable): - n/a
  • content-tag version (if applicable): - n/a
  • eslint-plugin-ember version (if applicable): - n/a

➕ Additional Context

prettier 3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions