-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[New] component detection: track React imports #3149
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
[New] component detection: track React imports #3149
Conversation
Test detection of Class Components and Stateless Function Components Lay scaffolding for other flavors of tests including further component types, pragma detection, and utils functions
The default React import and named React import specifiers are tracked during a Components.detect rules definition. Rules using Components.detect can access the default import specifier using `components.getDefaultReactImport()` and an array any named import specifiers using `components.getNamedReactImports()` Within a rule, these specifier nodes can be checked to ensure identifiers in scope correspond with the imported identifiers. Not treating this as semver-minor since it's not part of the documented API.
dddf6c2
to
146eefb
Compare
Codecov Report
@@ Coverage Diff @@
## master #3149 +/- ##
=======================================
Coverage 97.50% 97.51%
=======================================
Files 119 119
Lines 8103 8129 +26
Branches 2888 2895 +7
=======================================
+ Hits 7901 7927 +26
Misses 202 202
Continue to review full report at Codecov.
|
Note: I'm not treating this as semver-minor, since it's not really part of the public API. |
146eefb
to
a09debf
Compare
This PR adds a couple of basic tests to the existing
Components.detect
functionality.Next it adds a facility for detecting the imported React identifiers during a parse, and adds a simple test for that detection.
This is an extraction of work initiated in #2921 and supports that PR
I think having a test runner for the
Components.detect
utility was worthwhile in itself, and separated that test-runner functionality into its own commit.