How about use ast-grep
instead of regex
to transform attributes in jsx
#3346
zhiyuanzmj
started this conversation in
Ideas
Replies: 1 comment
-
Hey! ast-grep author here. That said, I respect unocss' decision and understand your constraints on choosing library. Best! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Now
transformerAttributifyJsx
using a complex regex to match attributes. It have many bug that I tried create a lot of PR to resolve, But new bugs are always found, such as:Above of the line is not work because of the regex not matched, and I don't know how to resolve.
unocss/packages/transformer-attributify-jsx/src/index.ts
Lines 40 to 42 in efdc358
Use ast-grep
So, I created the repo transformer-attributify-jsx-sg.
It's using
ast-grep
to match attributes, so have much more readable, simple and also fast.You can use
pnpm run bench
to benchmark test:If you agree I will create PR.
Beta Was this translation helpful? Give feedback.
All reactions