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.
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[New] Component detection: add
util.isReactHookCall
#3156[New] Component detection: add
util.isReactHookCall
#3156Changes from all commits
5a25380
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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'm a bit confused about these changes; could you walk me through why they're needed?
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.
The purpose of the
Components
test scaffolding is to allow exfiltration of theComponents.detect
locals to a scope in the test whereassert
is available, but without having to write a complete rule for every test with its ownProgram:exit
clause.My original implementation exfiltrated the
Components.detect
locals, but didn't make it easy to actually test some of those locals; in particular I couldn't testutils
because the utility functions expect AST nodes, and by the timeProgram:exit
fires, I've lost theCallExpression
nodes I need.These changes are intended to aid in writing new test cases for
Components
functionality; specifically, for testingutils
functionality whose methods expect many different AST node types besidesCallExpression
.Custom instructions passed into the
testComponentsDetect
get augmented and then incorporated into a custom rule, and when that rule runs over code the augmented instructions do two things:Components.detect
locals to the instruction callback. Ordinarily the instruction callback only receives anode
as an argument and relies on having been defined in theComponents.detect
closure to access the special locals it provides.instructionResults
as the visitor traverses the parsed AST; the log tracks which node type was traversed, and the result of that visit.Today
Taken together, these allow creation of test cases intended to read something like:
Tomorrow
Down the road, as we work to flesh out coverage for the code in
Components
, we can write new tests cases.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.
This isn't yet exercised, but I figured if someone needed to test
util
functionality when handling theProgram:exit
instruction it should behave the same way as handling any other instruction type.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 added a self-test section to the
test/util/Components
file in order to exercise the logging behavior while visitingProgram:exit
instructions.