Square brackets in filenames are hard to work around #789
Comments
This sounds like a bug in Prettier and ESLint, honestly. Normally you can quote filenames in bash and it will respect any unusual characters. Using
...and isn't as nice for things like |
Agreed, eslint does seem to have a bug, which I'm filing a report for (eslint/eslint#11940). The prettier situation can't really be improved, because those escapes are sort of necessary whatever tool you're working with. I'm not sure what you mean about multiple colons being impossible:
But I won't argue with you, especially if Next is taking the same approach 😄 |
Oh, I see what you mean about colons — there's ambiguity as to whether the dash belongs to the parameter or between parameters, is that right? At any rate, nothing more to do here. |
@staab Are you having issues with tools (editor plugins, etc) or is it just via the command line? Square brackets are special characters for globbing, but like Rich mentioned quoting the filenames should be enough. $ npx prettier 'src/routes/blog/[slug].svelte' |
On OSX:
I've come up with a solution for auto-formatting my project, but it's not pretty:
If you embed that in a package.json, you have to escape the slashes:
This unfortunately doesn't work for eslint, and I'm not quite sure why.
I propose some other naming convention; bash is of course rife with special characters, but
:
seems to work well:This has the added bonus of being more idiomatic for route params anyway.
The text was updated successfully, but these errors were encountered: