fix: prettier config resolving#1351
Conversation
🦋 Changeset detectedLatest commit: a175a49 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
cc @Andarist request for review 🙏 |
| let prettierInstance = getPrettierInstance(cwd); | ||
| let prettierConfig = await prettierInstance.resolveConfig(cwd); | ||
| let prettierConfig = await prettierInstance.resolveConfig( | ||
| path.join(cwd, "package.json") |
There was a problem hiding this comment.
I don't think this is completely correct. We are going to use the resolved config to format markdown files here so we should resolve a config for a markdown file.
We probably should resolve the config file separately for each file that we want to update but that's a separate issue.
There was a problem hiding this comment.
Aha you're right. Pushed a change!
packages/write/src/index.ts
Outdated
| const prettierInstance = getPrettierInstance(cwd); | ||
| const prettierConfig = await prettierInstance.resolveConfig(cwd); | ||
| const prettierConfig = await prettierInstance.resolveConfig( | ||
| path.join(cwd, "package.json") |
There was a problem hiding this comment.
There was a problem hiding this comment.
Aha you're right. Pushed a change!
| await prettierInstance.format(content, { | ||
| ...prettierConfig, | ||
| ...(await prettierInstance.resolveConfig(filePath)), | ||
| filepath: filePath, |
There was a problem hiding this comment.
it's interesting that we pass a filepath here but we don't do that in the other place. It's either redundant or we should add it in that other place. I don't know which one is more correct so 🤷♂️
fixes #1350