awmottaz / prettier-plugin-void-html

Use the void tag syntax
https://www.npmjs.com/package/@awmottaz/prettier-plugin-void-html
MIT License
54 stars 5 forks source link

svelte support #16

Closed mustafa0x closed 3 months ago

mustafa0x commented 5 months ago

Would love to use this with svelte files!

prettier.config.js

/** @type {import('prettier').Config} */
const config = {
    plugins: [
        '@awmottaz/prettier-plugin-void-html',
        'prettier-plugin-svelte',
        'prettier-plugin-tailwindcss',
    ],
    semi: false,
    singleQuote: true,
    tabWidth: 4,
    printWidth: 100,
    quoteProps: 'as-needed',
    bracketSpacing: false,
    arrowParens: 'avoid',
    overrides: [
        {
            files: '*.js',
            options: {
                tabWidth: 4,
            },
        },
        {
            files: ['*.html', '*.css'],
            options: {
                tabWidth: 2,
            },
        },
        {
            files: '*.svelte',
            options: {
                tabWidth: 4,
                parser: 'svelte',
                svelteStrictMode: false,
                svelteSortOrder: 'options-markup-scripts-styles',
                svelteIndentScriptAndStyle: false,
            },
        },
    ],
}

export default config
crisvp commented 3 months ago

The Svelte plugin uses its own parser, which has (or had) some support for void tags: https://github.com/sveltejs/prettier-plugin-svelte/blob/master/src/lib/elements.ts#L4-L19

Looking at the history of that repository, there is a lot of back-and-forth and partially implemented code around that feature. This is probably something the author of prettier-plugin-svelte could better address.

awmottaz commented 3 months ago

Thank you for your interest in this project!

As @crisvp explained, support for languages other than HTML (including Svelte) is implemented with entirely different parsers. This project currently supports HTML, only. I can probably do a better job of clarifying that in the project README.

Please let me know how it goes with prettier-plugin-svelte. That is probably the best home for this feature request. But if that project is unwilling and there is enough interest, maybe we can reconsider (I have also heard some interest for supporting Vue).

For now, closing this issue.