-
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
[docgen] Refactor code to use require() instead of JSON.parse(fs.readFileSync()) #38148
Merged
+96
−504
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…FileSync()) While working through #37929 I noticed that the tests in the `docgen` package read fixture data manually by chaining `JSON.parse()` and `fs.readFileSync()`, often at times separated by a number of lines. In this patch we're replacing those with the more natural `require()` statement which removes noise from the test modules and hopefully will also remove a point of confusion for those coming in to modify it. We shouldn't have to ask, "why is this code doing something that looks normal but is doing it in a notably different manner?" After reviewing the history of the work, initially introduced in #13329, I could find no explanation for the approach and found no discussion about it in the PR.
Size Change: 0 B Total Size: 1.13 MB ℹ️ View Unchanged
|
gziolo
added
[Type] Code Quality
Issues or PRs that relate to code quality
[Type] Automated Testing
Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
labels
Jan 21, 2022
gziolo
approved these changes
Jan 21, 2022
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.
Nice refactoring 👍
I also can’t find any benefit of keeping the old approach.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Tool] Docgen
/packages/docgen
[Type] Automated Testing
Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
[Type] Code Quality
Issues or PRs that relate to code quality
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
While working through #37929 I noticed that the tests in the
docgen
packageread fixture data manually by chaining
JSON.parse()
andfs.readFileSync()
,often at times separated by a number of lines.
In this patch we're replacing those with the more natural
require()
statementwhich removes noise from the test modules and hopefully will also remove a point
of confusion for those coming in to modify it. We shouldn't have to ask, "why is
this code doing something that looks normal but is doing it in a notably different
manner?"
After reviewing the history of the work, initially introduced in #13329, I could
find no explanation for the approach and found no discussion about it in the PR.
How has this been tested?
Ran the test suite and
yarn api-docs:ref
andyarn api-docs:blocks
andyarn api-docs:theme-ref
and compared output to ensure no changes appeared.Types of changes
Refactor to remove some complexity in an already-confusing test module and run with an idiomatic solution.
Checklist:
*.native.js
files for terms that need renaming or removal).