Skip to content

"Unterminated string constant" for valid syntax #498

@briancarbone

Description

@briancarbone

Describe the bug

The formatter changes this:

{@html '<script type="application/ld+json">' + json + '</script>'}

into this:

{@html '<script type="application/ld+json">' + json + "</script>"}

(note the quotes around the </script> tag)

Both are valid and both compile, but the language server complains about an 'unterminated string constant' in the second case.

Reproduction

Create a new Svelte file with json defined to some string value and the first {@html ...} tag, then run the language server format command.

Prettier with the Svelte plugin does this as well, likely respecting the singleQuote option.

Expected behaviour

The quotes will prefer to be double quotes, but the first string's single quotes won't change because that would require escaping the inner double quotes. Either both strings must use single quotes or both must use double quotes in order for the language server to be content. If there is a mismatch, it will complain.

System Info

NixOS
Vim 9.1

Which package is the issue about?

svelte-language-server

Additional Information, eg. Screenshots

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions