Skip to content
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: resolve Prettier config based on generated file #225

Merged
merged 1 commit into from
Mar 23, 2024

Conversation

gmathieu
Copy link
Contributor

Why

Resolves #219.

Recent versions of Prettier have changed the logic for resolving the config. This line appears to be the culprit:

const directory = file ? path.dirname(path.resolve(file)) : undefined;

When attemptPrettier is called, it passes process.cwd() as the "file" in the snippet above. It's common for typed-scss-modules to be executed from the project root, so the config search starts outside the project root and doesn't find anything.

What?

attemptPrettier resolves the prettier config based on the generated file path instead of process.cwd().

@gmathieu gmathieu mentioned this pull request Mar 23, 2024
@skovy
Copy link
Owner

skovy commented Mar 23, 2024

@gmathieu is this backwards compatible with previous versions of Prettier? wondering if this could break for people if they upgrade to this version and are not on the latest Prettier version

@skovy skovy merged commit c60f74e into skovy:master Mar 23, 2024
1 check passed
Copy link

🎉 This PR is included in version 8.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gmathieu gmathieu deleted the fix-prettier-config branch March 23, 2024 22:54
@gmathieu
Copy link
Contributor Author

@skovy it should be backwards compatible. As I understand it, Prettier was always meant to resolve its config based on a given file. Thanks for the quick turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prettier isn't applied
2 participants