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
[Fix] display-name
: fix misinterpreted function components
#3065
[Fix] display-name
: fix misinterpreted function components
#3065
Conversation
228b438
to
0ed3bdc
Compare
Codecov Report
@@ Coverage Diff @@
## master #3065 +/- ##
=======================================
Coverage 97.43% 97.43%
=======================================
Files 111 111
Lines 7522 7523 +1
Branches 2767 2767
=======================================
+ Hits 7329 7330 +1
Misses 193 193
Continue to review full report at Codecov.
|
@danielfinke unfortunately since you made this PR from a fork you don't own, i can't force push to it due to a github bug. Please do not close this PR and open a new one; what would be ideal is if you can add me to https://github.com/Unity-Technologies/eslint-plugin-react for long enough that I can get this PR landed. |
@ljharb I'll see what I can do - not sure what hoops I have to jump thru for that. If there's anything simple you need changed to the commit message, etc., I can do that on your behalf (as that may be quicker). Let me know. |
You may also be able to check the "allow edits" box in the RHS of the PR, but github's bug means that probably won't work (but is worth a shot) |
- when determining if an `ArrowFunctionExpression` returns JSX, do not check arguments to a returned `CallExpression`
0ed3bdc
to
1a5a970
Compare
Thanks! It'd be great if in the future you could make PRs from your own personal fork :-) |
ArrowFunctionExpression
returns JSX, do not check arguments to a returnedCallExpression
Arrow function expressions that return the result of a function call taking JSX arguments are incorrectly deemed to be returning JSX. This leads to some misinterpretations of arrow functions as function components, which are then flagged as "missing display name".
Examples:
ArrowFunctionExpression
asProperty
valueArrowFunctionExpression
as RHS ofAssignmentExpression
I think any other examples of
ArrowFunctionExpressions
that passutils.isInAllowedPositionForComponent
at https://github.com/yannickcr/eslint-plugin-react/blob/810806e58d5a611e6743227c91d859c2c02563bb/lib/util/Components.js#L648-L650 will hit this too (excl. aVariableDeclarator
as it's handled on L635 ahead of time).