-
Notifications
You must be signed in to change notification settings - Fork 569
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: prettier config resolving #1351
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 🙏 |
@@ -133,7 +133,9 @@ export default async function applyReleasePlan( | |||
}); | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha you're right. Pushed a change!
packages/write/src/index.ts
Outdated
@@ -31,7 +31,9 @@ async function writeChangeset( | |||
}); | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Aha you're right. Pushed a change!
) { | ||
await fs.writeFile( | ||
filePath, | ||
// Prettier v3 returns a promise | ||
await prettierInstance.format(content, { | ||
...prettierConfig, | ||
...(await prettierInstance.resolveConfig(filePath)), | ||
filepath: 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.
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