Skip to content

[v0.1.9] Unwanted removal of leading whitespace for concatenated class #71

@bennettdams

Description

@bennettdams

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

v0.1.9

What version of Tailwind CSS are you using?

v3.0.24

What version of Node.js are you using?

v16.13.0

What package manager are you using?

npm

What operating system are you using?

Windows

Reproduction URL

https://github.com/bennettdams/tailwind-prettier-whitespace-bug

Describe your issue

Version v0.1.9 introduced a change for frameworks like React that will introduce "bugs".

Here is a basic example. When a class consists of multiple concatenated strings, the plugin now removes the leading whitespace:

function Test() {
-      return <div className={"text-white" + " bg-red-100"} />;
+      return <div className={"text-white" + "bg-red-100"} />;
}

I use this format of concatenated strings for visibility when there are a lot of classes, e.g.:

className={
  'inline-flex items-center' +
  ' rounded-md p-2 shadow-sm focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-opacity-50' +
  ' bg-dlila text-white transition duration-75 ease-in-out hover:bg-dorange' +
  ' disabled:cursor-not-allowed disabled:bg-gray-200'
}

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