-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Check generated Jest snap file #3874
Check generated Jest snap file #3874
Conversation
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.
@yuya-takeyama Thanks for the pull request!
I left a few comments to address inline.
We don't already have guidelines for adding generated entries. We should probably write some, even if it's simple.
@lildude There are only 195 such files (but well distributed: 1-2 per repository). Is that enough? The rules run for every single file, so we probably want to impose some adoption requirement here as well...
lib/linguist/generated.rb
Outdated
@@ -82,7 +82,8 @@ def generated? | |||
generated_roxygen2? || | |||
generated_jison? || | |||
generated_yarn_lock? || | |||
generated_grpc_cpp? | |||
generated_grpc_cpp? || | |||
generated_jest_snap? |
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.
Could you add it after generated_by_zephir?
in the list? We prefer to place first the rules that don't require opening the file (to open it only if necessary).
lib/linguist/generated.rb
Outdated
# | ||
# Return true or false | ||
def generated_jest_snap? | ||
name.include?("__snapshots__") && name.end_with?(".snap") |
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.
Could you switch the two predicates? I expect the extension to be a better (and cheaper) discriminator than the path.
@pchaigno |
@pchaigno nudgy nudge nudge 😉 |
@lildude nudgy nudge nudge back 😜 |
Ooops. Missed my own ping 😊 Looks like we're up to 249 files. Still not really popular enough. Tagging as such. |
@pchaigno @lildude Found 64k files in this query. |
Uh, you're right. I updated mine and found ~150K files matching. (Looks like |
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.
And with the correct search string we get the popularity we need. Thanks for the correction and additions.
Welcome to Linguist.
Thank you! 🎉 😂 |
Oh 💩 I'm going to have to revert this PR. Sorry @yuya-takeyama. We marked Jest snapshot files as generated before in #3572 and had to revert it in #3579 following feedback from the community. This PR has effectively re-introduced the first PR and I completely forgot and missed it. We have #3584 open for discussion, though that discussion seems to have stalled. Please feel free to wake it up by commenting in that PR. If you want snapshots in your projects to be collapsed in diffs, please use the |
Arf! I forgot that and did not check :-/ |
See: #5567 (comment) References: #3579, #3874, #4507
See: #5567 (comment) References: #3579, #3874, #4507
This is to mark snapshot files generated by Jest (a testing framework by Facebook) as generated.
I want such files to be collapsed in GitHub diff.
ref: https://daveceddia.com/snapshot-testing-react-with-jest/
btw, does this project have a guideline for adding generated file rules?