Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preprocessEmbeddedTemplates appears to be processing jsdoc comments #183

Closed
gitKrystan opened this issue Jul 28, 2023 · 1 comment
Closed

Comments

@gitKrystan
Copy link

gitKrystan commented Jul 28, 2023

I'm not 100% sure ^^^ is what is happening.

I'm getting this report on my prettier plugin:

JS comments are being parsed by the plugin, and if the plugin finds invalid syntax, it throws errors. This is common in our codebase when people write example usages of a component invocation, and it even catches on some JSDoc comments. really, any JS comment with {{ will attempt to be parsed by the plugin.

example: this JSDoc comment with a type annotation containing an object, which looks like a double-curly template invocation:

  /**
   * Error message from loading the suggestions and whether the user can retry.
   * @type {{ errorMessage: string, canRetry: boolean} | undefined }}
   */

this breaks the prettier plugin

✖ yarn prettier:
[error] packages/addons/profile-shared/addon/components/generated-suggestions/generated-suggestion-edit-view.gjs: SyntaxError: Unexpected token (544:9)
[error]   542 |
[error]   543 |
[error] > 544 |  export default [__GLIMMER_TEMPLATE(`{{!voyager-i18n-resource}}
[error]       |         ^
[error]   545 | {{t-def "Original" key="i18n_original"}}
[error]   546 | {{t-def "Dismiss" key="i18n_dismiss"}}
[error]   547 | {{t-def "Something went wrong. Please try again." key="failure_toast"}}

something about the double-curly in the comment block is throwing off prettier, because when i delete that line it works fine

The plugin just passes the file contents to preprocessEmbeddedTemplates though:

https://github.com/gitKrystan/prettier-plugin-ember-template-tag/blob/1ab2de020a80cb507d69007aeaf6901b3f654221/src/parse.ts#L56-L66

@NullVoxPopuli
Copy link
Collaborator

This API has been removed in v4. You'll want to use content-tag for low level tooling work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants