question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
richex-cncommented, Oct 4, 2021

@yoyo930021 aha, So this seems to be related to VSCode.

BTW, Maybe can mention the useWorkspaceDependencies option around this sentence to prevent misunderstanding.

1reaction
yoyo930021commented, Oct 4, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found