Source code for route file getting modified by the CLI
Describe the bug
In my app I'm using double quote by default. Running tsr watch/tsr generate will update the code to use single quote. Is there a way to work around this?
export const Route = new FileRoute("/")
becomes
export const Route = new FileRoute('/')
Your Example Website or App
any of the file-base routing examples
Steps to Reproduce the Bug or Issue
NA
Expected behavior
NA
Screenshots or Videos
No response
Platform
NA
Additional context
No response
Currently it's hardcoded:
https://github.com/TanStack/router/blob/beta/packages/router-cli/src/generator.ts#L186-L189
But could be made configurable...
An easy solution for this use-case would be to use prettier and configure a script to run prettier immediately following tsr generate in package.json:
"scripts": {
"generate-and-format": "tsr generate && prettier --write 'src/[yourRoutesDirectory]/*.{js,jsx,ts,tsx}'"
}
Then any time you'd run tsr generate you can instead run npm run generate-and-format to achieve the desired formatting.
EDIT: this might be unnecessary advice. Looking at the source code schiller-manuel linked, it looks like prettier config is already honored.
why is it necessary to pass path to FileRoute when path is computed from the route file path?
TypeScript has no idea what file you’re in, or at least doesn’t expose it for use as a type.
I see. I was under the impression that the type inference would come from the generated routeTree file, rather than the path that gets passed to FileRoute.
It needs both. The path in the type is the key to getting the routes parent types.
#894 (released in v1.0.6) adds a configuration option for the quote style.
appreciate your fast response on this