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

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

[Bug] An apostrophe in a comment breaks formatting #228

Closed andrewtimberlake closed 10 months ago

andrewtimberlake commented 10 months ago

🐞 Describe the Bug

If an apostrophe (’) is in a comment, the formatter fails to format

πŸ”¬ Minimal Reproduction

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

interface TestComponentSignature {
  Element: HTMLDivElement;
  Args: {};
  Blocks: {
    default: [];
  };
}

export default class TestComponent extends Component<TestComponentSignature> {
  // Don’t use a real apostrophe or prettier will break
  @action
  testAction() {
    console.log('test action');
  }

  <template>
  <button type="button" {{on "click" this.testAction}}>
  {{yield}}
  </button>
  </template>
}

πŸ˜• Actual Behavior

["ERROR" - 08:43:55] Error formatting document.
["ERROR" - 08:43:55] failed to process all templates, 1 remaining
Error: failed to process all templates, 1 remaining
    at convertAst (file:///Users/andrew/dev/bbff/editor/node_modules/prettier-plugin-ember-template-tag/dist/prettier-plugin-ember-template-tag.js:70060:11)
    at Object.parse (file:///Users/andrew/dev/bbff/editor/node_modules/prettier-plugin-ember-template-tag/dist/prettier-plugin-ember-template-tag.js:70079:5)
    at async parse (file:///Users/andrew/dev/bbff/editor/node_modules/prettier/index.mjs:19362:11)
    at async coreFormat (file:///Users/andrew/dev/bbff/editor/node_modules/prettier/index.mjs:20683:7)
    at async formatWithCursor (file:///Users/andrew/dev/bbff/editor/node_modules/prettier/index.mjs:20885:14)
    at async Module.format2 (file:///Users/andrew/dev/bbff/editor/node_modules/prettier/index.mjs:24517:25)
["INFO" - 08:43:55] Formatting completed in 3ms.

πŸ€” Expected Behavior

The document should format

🌍 Environment

βž• Additional Context

None

gitKrystan commented 10 months ago

Thanks for the report. I believe this is a duplicate of https://github.com/gitKrystan/prettier-plugin-ember-template-tag/issues/191 as ’ is three bytes.