prettier-plugin-tailwindcss icon indicating copy to clipboard operation
prettier-plugin-tailwindcss copied to clipboard

Whitespace and duplicate classes not removed in Liquid files

Open ryanleichty opened this issue 11 months ago • 3 comments

What version of prettier-plugin-tailwindcss are you using?

v0.6.11

What version of Tailwind CSS are you using?

v4.0.9

What version of Node.js are you using?

v22.14.0

What package manager are you using?

npm

What operating system are you using?

macOS

Reproduction URL

A public GitHub repo that includes a minimal reproduction of the bug. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn't matter if your real project is private/confidential, since we want a link to a separate, isolated reproduction anyways. Unfortunately we can't provide support without a reproduction, and your issue will be closed with no comment if this is not provided.

Describe your issue

I'm using @shopify/prettier-plugin-liquid with prettier-plugin-tailwindcss and it's correctly sorting classes, but it's not removing whitespace or duplicate classes.

ryanleichty avatar Feb 28 '25 18:02 ryanleichty

I have the same issue.

{
    "plugins": [
        "@shopify/prettier-plugin-liquid",
        "prettier-plugin-tailwindcss"
    ],
    "tabWidth": 4,
    "useTabs": false
}

using html parser removes white space and duplicate classes but it breaks liquid tags indentation so it can not be used both at the same time

fret2buzz avatar Mar 19 '25 00:03 fret2buzz

        // Whitespace removal is disabled for Liquid
        // due to the way Liquid prints the AST
        // (the length of the output MUST NOT change)

https://github.com/tailwindlabs/prettier-plugin-tailwindcss/blob/63c22ded61a2b5b9eefe1646e5321b1ae0adde19/tests/plugins.test.ts

Disabled whitespace and duplicate class removal for Liquid and Svelte https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/276

fret2buzz avatar Mar 19 '25 00:03 fret2buzz

Nice, good find! That makes sense

ryanleichty avatar Mar 19 '25 00:03 ryanleichty

While unfortunate that we have to do this it is indeed intentional. If at some point things change (and I notice 😅) I'll update our AST handling.

thecrypticace avatar Jul 22 '25 21:07 thecrypticace