Skip to content

Escaping slashes are stripped #284

@hugovandevliert

Description

@hugovandevliert

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

0.5.3

What version of Tailwind CSS are you using?

3.1.7

What version of Node.js are you using?

18.7.0

What package manager are you using?

npm

What operating system are you using?

macOS

Reproduction URL

https://github.com/hugovandevliert/prettier-plugin-tailwindcss-escaping-slashes

Steps:

  1. npm i
  2. npx prettier --write foo.tsx
  3. git diff

Note: this reproduction repo uses different versions as those listed above.

Describe your issue

Escaping slashes in tailwind classes are stripped when used in combination with classNames.

Original code:

export default () => (
  <span
    className={classNames('md:p-2 m-1 m-3 p-4', "before:content-['\\ea53']")}
  />
);

After running npx prettier --write file_name.tsx:

export default () => (
  <span
    className={classNames('m-1 m-3 p-4 md:p-2', "before:content-['ea53']")}
  />
);

Note the missing \\.

Metadata

Metadata

Assignees

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