Skip to content

svelte parser transform is missing compatibility with @trivago/prettier-plugin-sort-imports #466

Description

@cyChop

What version of prettier-plugin-tailwindcss are you using? v0.8.0

What version of Tailwind CSS are you using? v4.3.2

What version of Node.js are you using? v24.18.0

What package manager are you using? npm

What operating system are you using? Ubuntu WSL

Reproduction URL

No reproduction URL, but TDD MR to come

Describe your issue

Description

The README's compatibility table lists @trivago/prettier-plugin-sort-imports (and others) as compatible, but that does not apply to .svelte files. Import sorting inside a .svelte file's <script> block is silently skipped, regardless of plugin order.

Root cause

svelte's defineTransform doesn't declare the compatible array configured in other transforms, which means Tailwind doesn't merge the parser wrappers from compatible plugins when used with Svelte. Any custom parse/preprocess logic provided by "compatible" plugins is lost, so import sorting never runs for .svelte files.

The html, css/scss/less transforms do declare their own compatible lists (prettier-plugin-organize-attributes, prettier-plugin-css-order respectively), so this looks like an oversight specific to the svelte transform rather than an intentional limitation.

Versions

  • prettier: 3.9.4
  • prettier-plugin-tailwindcss: 0.8.0
  • prettier-plugin-svelte: 3.5.2 (also reproduces on 4.1.1)
  • @trivago/prettier-plugin-sort-imports: 6.0.2
  • Node: v24.18.0

Suggested fix

Add a compatible array to the svelte defineTransform call mirroring the one used for babel/typescript, e.g.:

 defineTransform({
     staticAttrs: ["class"],
+    compatible: ["@trivago/prettier-plugin-sort-imports"],
     load: [{ name: "prettier-plugin-svelte", importer: () => import("prettier-plugin-svelte") }],
     parsers: { svelte: {} },
     ...
 })

NOTE: unless I'm mistaken, trivago's is the only plugin providing Svelte support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions