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

[Bug] Unexpected token error on route files #173

Closed
NullVoxPopuli opened this issue Nov 21, 2023 · 3 comments
Closed

[Bug] Unexpected token error on route files #173

NullVoxPopuli opened this issue Nov 21, 2023 · 3 comments

Comments

@NullVoxPopuli
Copy link
Member

NullVoxPopuli commented Nov 21, 2023

🐞 Describe the Bug

Error:

[error] app/templates/application.gts: SyntaxError: Unexpected token (8:2)
[error]    6 |
[error]    7 | export default Route(
[error] >  8 |   <template>
[error]      |  ^
[error]    9 |     {{pageTitle "ember-primitives"}}
[error]   10 |
[error]   11 |     <Layout />

Input

import Layout from 'docs-app/components/layout';
import pageTitle from 'ember-page-title/helpers/page-title';
import Route from 'ember-route-template';

export default Route(
  <template>
    {{pageTitle "ember-primitives"}}

    <Layout />
  </template>
);

🔬 Minimal Reproduction

the above file
this config:

'use strict';

module.exports = {
  singleQuote: true,
  printWidth: 100,
  plugins: ['prettier-plugin-ember-template-tag'],
  overrides: [
    {
      files: ['**/*.hbs'],
      options: {
        singleQuote: false,
      },
    },
    {
      files: ['**/*.gjs', '**/*.gts'],
      plugins: ['prettier-plugin-ember-template-tag'],
    },
  ],
};

😕 Actual Behavior

error

🤔 Expected Behavior

no error

🌍 Environment

  • prettier: - 3.3.1
  • prettier-plugin-ember-template-tag version: - 1.1.0
  • ember-template-imports version: - 3.4.2 -- this may be the problem, as ember-template-imports is a bad parser. It got us through things, but it has so many bugs.
@NullVoxPopuli NullVoxPopuli changed the title [Bug] Bug report [Bug] Unexpected token error on route files Nov 21, 2023
@gitKrystan
Copy link
Collaborator

The plugin as written doesn't expect <template> in that position. Hopefully it will be fixed with #162 .

@NullVoxPopuli
Copy link
Member Author

NullVoxPopuli commented Nov 21, 2023

The plugin as written doesn't expect in that position.

It shouldn't have expectations of anything 😅

Hopefully it will be fixed with #162 .

yeah, I'm thinking it would, real parser and all!

@gitKrystan
Copy link
Collaborator

Confirmed fixed by #162. Test added here: #188

NOTE that the output currently has a comma, which makes sense since in the current implementation, it's a function argument. If this is the syntax that ends up sticking, we might want to special case it.

output (copy-pasta'ed from snapshot so has some extra escaping):

import Layout from \\"docs-app/components/layout\\";
import pageTitle from \\"ember-page-title/helpers/page-title\\";
import Route from \\"ember-route-template\\";
export default Route(
  <template>
    {{pageTitle \\"ember-primitives\\"}}
    <Layout />
  </template>,
);

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