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

Prettier plugin hangs on <script> with some particular attributes #440

Closed
shadow-identity opened this issue May 3, 2024 · 3 comments
Closed

Comments

@shadow-identity
Copy link

shadow-identity commented May 3, 2024

Prettier plugin hangs on svelte file containing <script> tag with particular set of attributes.

This issue seems to be quite important, because it hangs everywhere -- on CI/CD systems, on pre-commit hooks, in editor. I can't find a way to work it around: even with <!-- prettier-ignore-start --> it hangs, and the only way I see is to add the component into .prettierignore (but this file seems to be ignored by pre-commit hooks).

I noticed it because it was failing on this file.

Finally I was able to make a minimal reproduction.

First reproduction -- it hangs:

    <script
        defer
        src='fds'
        on:load={() => {}}
    >
    </script>

Second reproduction -- it returns "Expected >" error on the fourth line

<script
    defer
    src='fds'
    on:load={() => {}}
>
</script>
[error] src/routes/Matomo.svelte: Expected >
[error]   2 |     defer
[error]   3 |     src='fds'
[error] > 4 |     on:load={() => {}}
[error]     |                ^

It does not hangs nor returns error if any of attributes are missing.

Reproduction

This reproduction results in hanging.

  1. Check out repository: https://github.com/shadow-identity/sveltejs-language-tools-issues-2363
  2. Install dependencies
  3. Run Prettier on it.

Expected behavior

It should never hang, because it is bad for CI/CD, pre-commit hooks, editors etc.

System and dependencies

  • OS: macOS 14.4.1 (23E224), intel
  • "prettier": "3.2.5",
  • "prettier-plugin-svelte": "3.2.3",
export default {
    plugins: [
        'prettier-plugin-svelte',
    ],
    printWidth: 80,
    semi: false,
    bracketSameLine: false,
    singleAttributePerLine: false,
    overrides: [{ files: '*.svelte', options: { parser: 'svelte' } }],
}
@shadow-identity
Copy link
Author

I found that it also happens on svelte-check: sveltejs/language-tools#2363
So this is probably a problem in language-tools.

@shadow-identity
Copy link
Author

I added the reproduction repository https://github.com/shadow-identity/sveltejs-language-tools-issues-2363

@shadow-identity
Copy link
Author

Could be related to sveltejs/svelte#9564

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

1 participant