-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
feature / enhancementNew feature or requestNew feature or requestp2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.SvelteKit cannot be used by a small number of people, quality of life improvements, etc.pkg:create-svelte
Description
Describe the bug
After generating new SvelteKit project with pnpm, formatting of svelte files doesn't work.
Reproduction
- Generate new SvelteKit project, with prettier formatter
pnpm create svelte@latest kit-prettiercd kit-prettierpnpm installpnpx prettier src/**/*.svelte --write- Error
What's more, VSCode with prettier plugin installed can't format Svelte files, failing with the following error:
Failed to resolve a parser, skipping file. If you registered a custom file extension, be sure to configure the parser
Severity
annoyance
Additional Information
I recognize that the team is aware of this issue because in package.json, the "format" command includes a flag that makes formatting work:
prettier --write --plugin-search-dir=. .
However, this doesn't work for VSCode prettier plugin, which can't locate the svelte-prettier-plugin.
The solution would be to add the following lines in .prettierrc
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
With this in place, the VSCode formatting would work and scripts in package.json won't need to have the --plugin-search-dir flag.
Related issue: sveltejs/prettier-plugin-svelte#155
Metadata
Metadata
Assignees
Labels
feature / enhancementNew feature or requestNew feature or requestp2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.SvelteKit cannot be used by a small number of people, quality of life improvements, etc.pkg:create-svelte