Skip to content

Parsing error with <script> in a string literal #402

@aradalvand

Description

@aradalvand

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

8.48.0

What version of eslint-plugin-svelte are you using?

2.33.0

What did you do?

I'm using Partytown with SvelteKit based on the official guide, here's the code I have in my +layout.svelte:

<script>
  import { partytownSnippet } from '@builder.io/partytown/integration'
</script>

<svelte:head>
  {@html `<script>${partytownSnippet()}</script>`}
</svelte:head>

eslint-plugin-svelte seems to get confused at the <script> part inside the string literal; I get the following error:

Parsing error: Unexpected keyword or identifier. eslint

What did you expect to happen?

The <script> inside the string should be recognized as a string.

What actually happened?

It seems to be confused by the <script> part, it may worth noting that if you changed <script> to any other tag like <style> here the error would go away, so the issue must be specific to <script>.

Link to GitHub Repo with Minimal Reproducible Example

Repro: https://github.com/aradalvand/eslint-plugin-svelte-bug

Go to src/routes/+layout.svelte — you'll see the error:

image

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions