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

feat: Only format changed files with Prettier #670

Merged
merged 5 commits into from
Oct 9, 2024

Conversation

onurtemizkan
Copy link
Collaborator

@onurtemizkan onurtemizkan commented Sep 11, 2024

Following up on #644

Formatting changed/untracked files only with Prettier.

@onurtemizkan onurtemizkan requested a review from Lms24 September 11, 2024 08:46
Copy link

github-actions bot commented Sep 11, 2024

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 32a1311

}
});
childProcess.exec(
`npx prettier --write ${prettierSupportsCache ? '--cache' : ''} .`,
Copy link
Member

@Lms24 Lms24 Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work if users themselves didn't use --cache before? Reading the documentation, I'm not sure because it sounds like a cache already needs to be populated so that a file is skipped.

I'm not really worried about the performance aspect but rather that we format files that users (for whatever reason) haven't formatted before or don't want formatted.

If --cache works for first-time use, no worries, we can use it! Otherwise: We already have some logic around detecting new and changed files via git at the beginning of the wizard. Maybe we could re-use that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. I thought a cache was populated anyway via regular prettier use. But it looks like it was a leftover.

I have switched to using git. Thanks for pointing that out!

@onurtemizkan onurtemizkan changed the title feat: Use Prettier's cache option to only format files that are modified / created feat: Only format changed files with Prettier Sep 20, 2024
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it with a SvelteKit project. Worked like a charm. Thanks Onur (and sorry for the wait, I was ooo last week).

@Lms24 Lms24 merged commit db21946 into master Oct 9, 2024
14 checks passed
@Lms24 Lms24 deleted the onur/prettier-on-changed branch October 9, 2024 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants