T
TanStack•2y ago
rising-crimson

prettier on lint-staged throws an error with files starting with $, have you handled that?

I know It's not an error caused by the router, but I'd love to hear if you have found any workaround to make this work. In short, tokens starting with $ are removed so src/routes/$id.tsx is parsed as src/routes/.tsx which obviously does not exist and prettier can't find it
4 Replies
painful-plum
painful-plum•2y ago
what exactly is the issue? can you please provide a minimal example?
rising-crimson
rising-crimsonOP•2y ago
Yes sorry, I though it was something frequent but apparently it's not. They talk about it here: https://github.com/lint-staged/lint-staged/issues/962
GitHub
Error when lint staging files with $ in its name · Issue #962 · lin...
Description When I try eslint path/to/file/$something.foo it tries to resolve $something as an variable (I'm on Linux) and it becomes only path/to/file/.foo since variable does not exist. Is th...
rising-crimson
rising-crimsonOP•2y ago
The issue is that lint-staged ends up running prettier --write src/routes/.tsx instead of prettier --write src/routes/$id.tsx (basically $id disappears) I see in the issue they suggest using lint-staged.config.js, I'm giving it a try and I think I made it work. It's definitely not tanstack router's fault, but router users that are also using lint-staged might end up in this situation, it might be worth mentioning it somewhere in the docs, what do you think? I added a comment on the issue with my solution, it works 😄
painful-plum
painful-plum•2y ago
not sure how common this is that it warrants mentioning in the docs

Did you find this page helpful?