New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --noglob cli option for processing exact the passed files #6492
Conversation
With this option, prettier will work like eslint. There are no such logic with glob) |
This CLI option should be also helpful to those using dynamic routing in Next.js https://github.com/zeit/next.js#dynamic-routing. The PR resolves #6344. Instead of tweaking Prettier, the solution might actually come from lint-staged/lint-staged#698 (see discussion in lint-staged/lint-staged#676). The benefit in that approach is that we don't need any extra CLI flags in Prettier, which is great. If this PR gets accepted, it might be worth updating https://prettier.io/docs/en/precommit.html as well. |
If okonet/lint-staged will provide escaped filenames, than eslint/eslint will not find them, because there are no globbing on [] and it will try to find file like |
I'm using Next.js with a Prettier file watcher and this feature would be a lifesaver for me. As it stands dynamic routes throw errors on save, and I can't see an easy solution to this problem. Thanks for the effort @AzazKamaz - hope it gets accepted. |
Random thought: Maybe it would even be nice if Prettier didn’t support |
Same thread in stylelint stylelint/stylelint#4286, here eslint solution https://github.com/eslint/eslint/blob/d08683e3c807f92daf266894093c70f8d5ac6afa/lib/cli-engine/file-enumerator.js#L292, i think we should use it |
@evilebottnawi Ah – first treat as literal file name, and if no such file exists then treat as glob? Sounds good to me. (We could potentially end up in the reverse situation – a file on disk prevents someone’s glob to be treated as a glob, but that should be workaround-able by adjusting the glob pattern.) |
This is now tracked in #6854. |
I faced problem with configuring git hooks with lint-staged on sapper framework. lint-staged starts prettier and passes changed files with arguments, but in sapper there are routes with name
[name].svelte
, and prettier thinks that is is a regexp. So I have added parameter (--noglob) that disables any logic on filenames and just keeps it as you write, so it will process exactly what you have passeddocs/
directory)CHANGELOG.unreleased.md
file following the template.✨Try the playground for this PR✨