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

plugin is parsing JS comments and throws errors #84

Open
hmajoros opened this issue Jul 28, 2023 · 2 comments · Fixed by ember-cli/eslint-plugin-ember#1920 or ember-cli/eslint-plugin-ember#1942

Comments

@hmajoros
Copy link

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

recommendation: just don't parse the contents of JS comment blocks

Originally posted by @hmajoros in #42 (comment)

@gitKrystan
Copy link
Collaborator

Thanks @hmajoros .

I won't be able to look into this for a few weeks, but if someone has time to investigate, I'd look into...

...to see what the root cause is.

@gitKrystan
Copy link
Collaborator

Can you confirm this is still an issue with the latest version?

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