mohammadsiyou / prettier-plugin-twin.macro

Sort Tailwind and Twin classes based on recommended class order of Tailwind using Prettier.
11 stars 1 forks source link

Wrong formatting #1

Closed u3u closed 1 year ago

u3u commented 2 years ago

1. Grouping with only arbitrary attributes

const Content = tw.div`[h1,h2,h3,h4,h5,h6]:([font-size:revert] [font-weight:revert])`
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
const Content = tw.div`[h1,h2,h3,h4,h5,h6]:[font-size:revert] [font-weight:revert]`
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
const Content = tw.div`[font-weight:revert] [h1,h2,h3,h4,h5,h6]:[font-size:revert]`

2. Multiple :nth-child selectors on the same line

const Test = tw.div`[:nth-child(2)]:(-translate-x-1.5 translate-y-1.5) [:nth-child(3)]:(-translate-x-3 translate-y-3)`
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
const Test = tw.div`[:nth-child(2)]:(-translate-x-1.5 translate-y-1.5) nth-child(3)]:(-translate-x-3 translate-y-3)`
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
const Test = tw.div`nth-child 3 ] ) translate-y-3 :(-translate-x-3 [:nth-child(2)]:(-translate-x-1.5 translate-y-1.5)`
wottpal commented 1 year ago

@mohammadsiyou any idea about how to fix this?

(btw this is a dope plugin, just discovered it today 🔥)

wottpal commented 1 year ago

@mohammadsiyou I've found another one related to styling data attributes. Would be great to get this sorted out quickly :)

Makes this (great) plugin unusable for us at the moment, unfortunately.

data-[state=open]:(border-green-500) ✅
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
data-[state=open] :(border-green-500) ❌
mohammadsiyou commented 1 year ago

@u3u @wottpal Sorry for late update! New version released and reported bugs fixed:)

wottpal commented 1 year ago

Hey @mohammadsiyou, thank you so much for revisiting this one :)

Unfortunately, after the update, a lot of prettier errors are thrown now:

basis-[45%]
Error: An ending bracket ')' wasn’t found for these classes:

or something more complex:

[:not([data-state='active'] &)]:hidden
Error: An ending bracket ')' wasn’t found for these classes:

So I basically can't use it. 🙈

In a separate environment though, my case (https://github.com/mohammadsiyou/prettier-plugin-twin.macro/issues/1#issuecomment-1358359266) seems to work now. 🥳

mohammadsiyou commented 1 year ago

@wottpal New version is released and bugs are fixed.

wottpal commented 1 year ago

Amazing, @mohammadsiyou! It's almost working error-free for me. Right now, this seems to be the only case (when grouping !importants) that throws an error:

!(w-full grow justify-start justify-between rounded-none py-9 text-red-500 text-lg)
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
(w-full! ) grow justify-start justify-between rounded-none py-9 text-red-500 text-lg
mohammadsiyou commented 1 year ago

@wottpal Group important issue is fixed.