Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formating adds escape backslashes again and again with each run in 0.6.5 #294

Open
Cielquan opened this issue Jun 14, 2024 · 6 comments · Fixed by #295
Open

Formating adds escape backslashes again and again with each run in 0.6.5 #294

Cielquan opened this issue Jun 14, 2024 · 6 comments · Fixed by #295

Comments

@Cielquan
Copy link

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

v0.6.4

What version of Tailwind CSS are you using?

v3.4.3

What version of Node.js are you using?

v20.12.1

What package manager are you using?

pnpm

What operating system are you using?

Linux / Ubuntu

Reproduction URL

Because the reproduction code is so small I skipped creating a repo. If you want me to I can make one though.

Code at start:

const Test = () => {
  return <div className="after:content-['\2026']" />;
};

Code after 1st run:

const Test = () => {
  return <div className="after:content-['\\2026']" />;
};

Code after 2nd run:

const Test = () => {
  return <div className="after:content-['\\\\2026']" />;
};

Describe your issue

I just updated from 0.5.10 to 0.6.4 and suddenly the backslash in the code snippet above kept multiplying itself(s). Versions 0.6.4, 0.6.3, 0.6.2 are affected. 0.6.1 is ok.

I did not except the backslash(es) for the octal escape sequence to be escaped again and again.

Repro:

  1. Install prettier and plugin
  2. Create file with content from above
  3. Run prettier multiple times and set the backslashes comin in
@thecrypticace
Copy link
Contributor

Fix released in v0.6.5 — thanks for reporting! 👍

@Cielquan
Copy link
Author

Thanks for the quick fix and release 👍🏾

@jonaschlegel
Copy link

@thecrypticace thanks for fixing this bug in the released v0.6.5, but there still seems to be an issue:

  • extra spaces in the className get removed by prettier-plugin-tailwindcss
  • extra backslashes are added

Code at start:

const Test = () => {
  return <div className="after:content-['\2026'] text-white " />;
};

Code after 1st run:

const Test = () => {
  return <div className="text-white after:content-['\\2026']" />;
};

Adding another space:

const Test = () => {
  return <div className="text-white after:content-['\\2026'] " />;
};

Code after 2nd run:

const Test = () => {
  return <div className="text-white after:content-['\\\\2026']" />;
};

@thecrypticace
Copy link
Contributor

huh interesting I'll look into it

@thecrypticace thecrypticace reopened this Jun 25, 2024
@thecrypticace thecrypticace changed the title Formating adds escape backslashes again and again with each run - starting with 0.6.2 Formating adds escape backslashes again and again with each run - starting with 0.6.5 Jun 25, 2024
@thecrypticace thecrypticace changed the title Formating adds escape backslashes again and again with each run - starting with 0.6.5 Formating adds escape backslashes again and again with each run in 0.6.5 Jun 25, 2024
@karlhorky
Copy link

karlhorky commented Jul 3, 2024

Workaround

If you're experiencing this, the current workaround (as mentioned by @Cielquan in the PR description) is to downgrade to prettier-plugin-tailwindcss@0.6.1

(as long as you don't need the features/fixes introduced in the latest versions)

@karlhorky
Copy link

@thecrypticace did you have some time to take a look at this yet?

In case you know generally where the problem is but don't have the bandwidth currently to fix it, maybe a community member could contribute a fix with your guidance...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants