-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[code-infra] Refactor prettier
config resolving
#18720
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
Conversation
Deploy preview: https://deploy-preview-18720--material-ui-x.netlify.app/ Bundle size reportTotal Size Change: ▼-4.77KB(-0.04%) - Total Gzip Change: ▼-1.91KB(-0.05%) Show details for 100 more bundles (22 more not shown)@mui/x-data-grid-premium parsed: ▼-410B(-0.07%) gzip: ▼-115B(-0.07%) |
const prettierConfigPath = await prettier.resolveConfigFile(); | ||
if (!prettierConfigPath) { | ||
throw new Error( | ||
`Could not resolve prettier config file. | ||
Please provide a valid prettier config path or ensure that a prettier config file exists in the project root.`, | ||
); | ||
} |
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.
const prettierConfigPath = await prettier.resolveConfigFile(); | |
if (!prettierConfigPath) { | |
throw new Error( | |
`Could not resolve prettier config file. | |
Please provide a valid prettier config path or ensure that a prettier config file exists in the project root.`, | |
); | |
} | |
const prettierConfigPath = await resolvePrettierConfigPath() |
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.
Tried it: 03d59e9
I wanted to limit the scope of changes.
For that to work we need to unify file extensions or move to tsx for execution, but it seems that the latest "trend" is towards going for mjs
, so I didn't want to do it. 🤔
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.
Make sense 👍
prettier
config resolvingprettier
config resolving
let resolvedPrettierConfigPath = prettierConfigPath; | ||
if (!resolvedPrettierConfigPath) { | ||
// If no prettier config path is provided, use the default one | ||
resolvedPrettierConfigPath = await resolvePrettierConfigPath(); |
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.
shouldn't we pass filename as an argument here? the goal is to obtain the config that applies to the file we're writing to. I wonder why we'd need the prettierConfigPath parameter at all.
Follow-up on #18716 (comment).