ember-tooling / prettier-plugin-ember-template-tag

A prettier plugin for formatting Ember template tags
MIT License
22 stars 12 forks source link

[Bug] Incorrect behavior when template contains a #222

Closed HeroicEric closed 11 months ago

HeroicEric commented 11 months ago

🐞 Describe the Bug

Components are not formatted correctly when <template> contains unicode characters such as βœ“ or Β© rather than &check; or &copy;.

πŸ”¬ Minimal Reproduction

Failing test added in https://github.com/gitKrystan/prettier-plugin-ember-template-tag/pull/221

import Component from '@glimmer/component';

export interface Signature {
  Element: HTMLElement,
  Args: {}
  Yields: []
}

/** It's a component */
class MyComponent extends Component<Signature> {
  <template>
    βœ“
  </template>
}

function hello() {
  return 'Hello';
}

function world() {
  return 'World';
}

πŸ˜• Actual Behavior

import Component from "@glimmer/component";

export interface Signature {
  Element: HTMLElement;
  Args: {};
  Yields: [];
}

/** It's a component */
class MyComponent extends Component<Signature> {
  <template>βœ“</template>
}
function hello() {
  return "Hello";
}
function world() {
  return "World";
}

Note: The newlines are removed between the helper functions.

πŸ€” Expected Behavior

import Component from "@glimmer/component";

export interface Signature {
  Element: HTMLElement;
  Args: {};
  Yields: [];
}

/** It's a component */
class MyComponent extends Component<Signature> {
  <template>βœ“</template>
}

function hello() {
  return "Hello";
}

function world() {
  return "World";
}

🌍 Environment

βž• Additional Context

Replacing the direct symbols with the HTML entity codes like &check; fixes the formatting issue (and is preferred anyway)

gitKrystan commented 11 months ago

Thanks for the report! This sounds like a duplicate of https://github.com/gitKrystan/prettier-plugin-ember-template-tag/issues/191