sveltejs / prettier-plugin-svelte

Format your svelte components using prettier.
MIT License
715 stars 95 forks source link

No parser could be inferred for .svelte files #368

Closed mikemaccana closed 11 months ago

mikemaccana commented 1 year ago

When running:

$ npx prettier --ignore-path .gitignore --write --plugin-search-dir=. "**.svelte"

The following error occurs:

[error] No parser could be inferred for file: src/lib/somefile.svelte

I may be missing something - the README for this repo says it's for svelte but the README only mentions .html files, which is not the standard extension for Svelte.

eswat2 commented 11 months ago

i had to disable formatting of svelte files in my projects because of this issue. It all worked fine a month ago, but prettier currently fails to parse svelte files with the existing version of prettier-plugin-svelte.

LWJerri commented 11 months ago

Have the same issue.

eswat2 commented 11 months ago

tweaked my .prettierrc.json:

    "plugins": [ 
        "prettier-plugin-svelte", 
        "prettier-plugin-tailwindcss" 
    ],

and saw this error:

[error] src/components/vehicle-list.svelte: Error: printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/en/plugins.html#optional-embed
[error]     at printEmbeddedLanguages (file:///Users/richardhess/github/svelte/autos-s4e/node_modules/prettier/index.mjs:17963:11)
[error]     at printAstToDoc (file:///Users/richardhess/github/svelte/autos-s4e/node_modules/prettier/index.mjs:18094:9)
[error]     at async coreFormat (file:///Users/richardhess/github/svelte/autos-s4e/node_modules/prettier/index.mjs:18405:14)
[error]     at async formatWithCursor (file:///Users/richardhess/github/svelte/autos-s4e/node_modules/prettier/index.mjs:18603:14)
[error]     at async formatFiles (file:///Users/richardhess/github/svelte/autos-s4e/node_modules/prettier/internal/cli.mjs:6778:18)
[error]     at async main (file:///Users/richardhess/github/svelte/autos-s4e/node_modules/prettier/internal/cli.mjs:6970:5)
[error]     at async Module.run (file:///Users/richardhess/github/svelte/autos-s4e/node_modules/prettier/internal/cli.mjs:6924:5)
All matched files use Prettier code style!
error Command failed with exit code 2.

Error: printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/en/plugins.html#optional-embed

dummdidumm commented 11 months ago

That's due to this plugin not support prettier v3 yet. See #335 to track it.