Formatting with pug, the prettier-ignore causes the code to be deleted
See original GitHub issue- I have searched through existing issues
- I have read through docs
- I have read FAQ
- I have tried restarting VS Code or running
Vetur: Restart VLS
Info
- Platform: Win 21H1
- Vetur version: 0.34.1
- VS Code version: 1.60.2
Problem
When using //- prettier-ignore
or // prettier-ignore
at the end of the <template lang="pug">
, the code will be accidentally deleted:
<template lang="pug">
div
//- prettier-ignore
img.normal(src="1.jpg")/
.normal(data-a='1', data-b='2')
//- prettier-ignore
p hello
</template>
result:
<template lang="pug">
div
//- prettier-ignore
img.normal(src="1.jpg")/
.normal(data-a='1', data-b='2')
</template>
The @prettier/plugin-pug plugin also had problems formatting pug files before 1.16.7 release, but this was fixed in 1.16.7
As the documentation says: It’ll prefer to use the local version. So I assume that when I install version 1.16.7 locally, prettier will also use this version for work.
But unfortunately I got the unexpected result of the <template lang="pug">
for formatting vue files mentioned in #292
There are no err message in Panel -> Output -> Vue Language Server.
Reproducible Case
I wrote a sample see https://github.com/richex-cn/sample-pug-formatting/blob/master/src/Test.vue
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Bug: prettier-ignore causes the code to be deleted #292 - GitHub
Awesome! I successfully got the desired result in the pug file! But the problem still exists when using Vetur to format the vue...
Read more >Formatting with pug, the prettier-ignore causes the code ... - Issuehunt
Formatting with pug, the prettier-ignore causes the code to be deleted #3165 ... I have tried restarting VS Code or running Vetur: Restart...
Read more >Ignoring Code - Prettier
Use .prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
Read more >@prettier/plugin-pug - npm
You can disable code formatting for a particular element by adding //- prettier-ignore comments in your pug templates:.
Read more >vscode prettier ignore not working - You.com | The AI Search ...
First, We should set the default formatter in vscode, just open code-->preferences-->settings of vscode, and input default formatter in the right pane to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@yoyo930021 aha, So this seems to be related to VSCode.
BTW, Maybe can mention the useWorkspaceDependencies option around this sentence to prevent misunderstanding.
Thank you, I update it.