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.

Prettier Pug Plugin: Not formatting as expected.

See original GitHub issue

Info

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ
  • Platform: macOS
  • Vetur version: 0.28.0 Problem Problem

Problem

Pug templates don’t use @prettier/plugin-pug specific settings. According the developer over on @prettier/plugin-pug I think this is because the package needs to be updated in Vetur’s package.json.

Original Issue I opened on @prettier/plugin-pug

Issue: https://github.com/prettier/plugin-pug/issues/124 Related Issue: https://github.com/vuejs/vetur/issues/527

Temporary Solution

I had to downgrade Vetur’s version to 0.27.3, and then any @prettier/plugin-pug settings work. I will open a request on the Vetur repo and see about getting them to update to the current version.

Input

<template lang="pug">
button.hello( class="world" disabled @click="handleClick"  )
</template>

Expected Output

<template lang="pug">
button.hello.world( disabled  @click="handleClick" )
</template>

Actual Output

<template lang="pug">
button.hello.world( disabled, @click="handleClick"  )
</template>

Additional Context

My project has a .prettierrc file with the options

{
  "semi": false,
  "arrowParens": "always",
  "printWidth": 600,
  "pugAttributeSeparator": "none"
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
Shinigami92commented, Oct 4, 2020

@octref A bunch of new features made it into 1.8.0 🎉
Would be really nice if you upgrade and release 😃

3reactions
lehnicommented, Oct 10, 2020

@octref funny to cross paths again! I started working on plugin-pug recently (after taking note of its existence through Vetur), you can see me pop up in the commits here and there 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

@prettier/plugin-pug - npm
Installing @prettier/plugin-pug either locally or globally may require you to restart the editor if formatting does not work right away.
Read more >
Plugins - Prettier
Plugins are ways of adding new languages or formatting rules to Prettier. ... When plugins cannot be found automatically, you can load them...
Read more >
@prettier/plugin-pug | Yarn - Package Manager
Installing @prettier/plugin-pug either locally or globally may require you to restart the editor if formatting does not work right away. Implementation details.
Read more >
Prettier 2.1: new --embedded-language-formatting option and ...
Prettier 2.1 [error] test.ts: SyntaxError: Did not expect a type annotation here. ... @prettier/plugin-pug is required for this example.
Read more >
Efficient Code Analyzing and Formatting (for Vue.js) with ...
As we see later, there exists an official ESLint Plugin for Vue.js ... Its only purpose is to reformat source code; but Prettier...
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