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/plugin-pug support

See original GitHub issue

Hello,

Thank you for svelte. My current workflow is vue, and I have been happily using prettier-eslint with vscode to format all my pug templates. I decided to explore svelte last night but had some issues with the environment config.

I used preprocess to enable pug compiling and that was smooth, but for some reason I’m not able to get prettier to format pug templates. I tried a few things including invoking prettier from the cli and it also wouldn’t format the pug template. If you could shed some light I will surely appreciate it.

Is what I’m trying to do is supported?

<template lang="pug">
    main
        h1.something(
            x="a",

            b="a"  )
            | Hello {name}

</template>
    "[svelte]": {
        "editor.formatOnSave": true,
        "editor.formatOnType": false,
        "editor.formatOnPaste": false,
        "editor.highlightActiveIndentGuide": false,
        "editor.renderIndentGuides": false,
        "editor.defaultFormatter": "svelte.svelte-vscode"
    },
module.exports = {
    trailingComma: "es5",
    tabWidth: 4,
    semi: true,
    printWidth: 100,
    singleQuote: true,
    overrides: [
        {
            files: "*.svelte",
            options: {
                // "svelteSortOrder" : "scripts-markup-options-styles",
                // "svelteStrictMode": true,
                svelteBracketNewLine: false,
                // "svelteAllowShorthand": false,
                svelteIndentScriptAndStyle: false,
                tabWidth: 8,
                pugTabWidth: 8,
                pugPrintWidth: 90,
                pugSingleFileComponentIndentation: false,
                pugWrapAttributesThreshold: 3,
                pugClassNotation: "as-is",
                pugWrapAttributesPattern: "^v-(if|else|for)",
                pugSortAttributes: "asc",
                pugClosingBracketPosition: "last-line",
            },
        },
    ],
};
// svelte options above are functional and they work. But not the pug options.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
dummdidummcommented, Sep 12, 2021

If you install prettier and the latest version of prettier-plugin-svelte and @prettier/plugin-pug , Pug will be formatted within <template lang="pug"> tags now.

0reactions
basarancommented, Apr 21, 2021

Hello, https://github.com/sveltejs/prettier-plugin-svelte/issues/57 seems to be different than what I encountered. In that issue, the author is trying to use prettier within eslint as a plugin. I tried to use prettier-eslint module, which executes prettier first and eslint second. So conflicting rules shouldn’t really matter, eslint should just override any changes made by prettier.

I will debug prettier-eslint over the weekend and update here with my findings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

prettier/plugin-pug - GitHub
This plugin adds support for the Pug language to Prettier. Getting started; Usage; Configuration; Workarounds / Known Issues; Integration with editors ...
Read more >
@prettier/plugin-pug - npm
Prettier Pug Plugin. Latest version: 2.3.0, last published: a month ago. Start using @prettier/plugin-pug in your project by running `npm i ...
Read more >
Prettier Plugin Pug | Format your pug code with Prettier
This plugin adds support for the Pug language to Prettier. Released under the MIT License. Copyright © 2019-2022 Christopher Quadflieg.
Read more >
@prettier/plugin-pug | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Plugins - Prettier
Plugins are ways of adding new languages or formatting rules to Prettier. Prettier's own implementations of all languages are expressed using the plugin...
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