-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
fix(cli): pass in parser to prettier format to avoid deprecation warning #662
fix(cli): pass in parser to prettier format to avoid deprecation warning #662
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/gregberge/svgr/C9HyWFMP1e57K2tVNPM9rMfc1Nxt |
packages/cli/src/dirCommand.ts
Outdated
const prettierRcConfig = opts.runtimeConfig | ||
? await resolveConfig(filepath, { editorconfig: true }) | ||
: {} | ||
const prettierFileInfo = await getFileInfo(filepath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to be in a Promise.all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some more digging in the prettier source code. getFileInfo
ends up using resolveConfig again and inferring based on filepath. So to avoid extra work (and extra IO) it's better to just pass in file path as an option. Updated the code and verified by running the CLI.
0734f69
to
36515ba
Compare
36515ba
to
9f93734
Compare
Summary
Prettier now gives warning when not being able to infer correct parser for files. It can infer by checking filepath or when explicitly setting parser. See issue and comment: prettier/prettier#4763 (comment)
This causes outputs such as:
There are different ways to solve this:
In this PR I've chosen the latter option as it feels more explicit. In plugin-prettier it is hardcoded to babel but as I see it that might not be correct here?
Test plan
Tested by running and verifying that prettier deprecation warning is gone.