getgrit / gritql

GritQL is a query language for searching, linting, and modifying code.

Home Page:https://docs.grit.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid replace when output pattern has missing curly

tennox opened this issue · comments

I found weird behaviour when I was missing a closing curly in my output pattern:

`const navigate = useNavigate()` 
=> `const {locnav, location, navigate = useLocationNavigate()`

It didn't fail but weirdly removes a completely unrelated statement's const prefix:
https://app.grit.io/studio?key=ndJC5UF8gvqYnDDY0urXP

I can see if that's a too weird edge-case and I should just fix my code, but I wanted to let you know in case you want to refine your UX 🤔

Thanks for the report. We have some matching heuristics around rewrites that this is capturing, but those heuristics are only really designed to work with well-structured rewrites.