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

⚠️ Read this about TS parsing errors before submitting an issue ⚠️ #1111

Open
baseballyama opened this issue Feb 28, 2025 · 5 comments

Comments

@baseballyama
Copy link
Member

baseballyama commented Feb 28, 2025

There have been reports of the error "Parsing error: Unexpected token {", which occurs due to missing configurations in eslint.config.js.

Please refer to the documentation and ensure your settings are correct. If the error persists despite correct configuration, feel free to open an issue.

https://github.com/sveltejs/eslint-plugin-svelte?tab=readme-ov-file#typescript-project

@baseballyama baseballyama pinned this issue Feb 28, 2025
@AlbertMarashi
Copy link

If it helps anyone:

    {
        files: ["**/*.svelte", "**/*.svelte.ts"],
        languageOptions: {
            parserOptions: {
                projectService: true,
                extraFileExtensions: [".svelte", ".svelte.ts"],
                parser: ts.parser,
                svelteFeatures: {
                    experimentalGenerics: true,
                },
                svelteConfig,
            },
        },
    },

@Lippiece
Copy link

Lippiece commented Apr 9, 2025

I'm still getting this with config from README (without svelteConfig).

It happens when I have on inline handlers that are multiline.

                onchange={async event => {
                  const input = event.target as HTMLInputElement
                  const file = input.files?.[0]

                  if (file) {
                    const img = document.querySelectorAll(`form img`)[
                      index
                    ] as HTMLImageElement
                    img.src = URL.createObjectURL(file)
                  }
                }}

@Lippiece
Copy link

Lippiece commented Apr 9, 2025

It happens when I have on inline handlers that are multiline.

Scratch that, it happens with TS inside handlers.

...and it looks like also when you have async functions in handlers:

        onsubmit={async ()=> {}}

@baseballyama
Copy link
Member Author

@Lippiece I can not reproduce this. Can you create a new issue with reproduction?

@Lippiece
Copy link

Lippiece commented Apr 10, 2025

@Lippiece I can not reproduce this. Can you create a new issue with reproduction?

Thanks for checking this out. I couldn't do it. The same config works if eslint is installed locally, but not globally. Maybe someone else will have an idea.

...looks like the problem was in svelte package missing globally. Silly me.

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

3 participants