-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[BUG] react/prop-types - false positive when returning null #2703
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
Comments
Same problem for me |
I assume that if you flip the first example so the null is returned conditionally and the jsx unconditionally, that it’ll be detected as a component properly? |
@ljharb exactly, no issue if the null is returned in the condition |
Specifically, component detection should be looking at every return value, and if any of them are jsx, and if all of them are possibly valid component return values (jsx, null, or a string/number/array of those things), then it should be detected as a component. (cc @alexzherdev) |
Hi @gcourtemanche ! |
Hi @hank121314, thanks for helping me with this issue. I tried running eslint using commit
|
hmm, sorry for that. |
If you don’t mind, could you please give me full error code?
If the occurred file is private you can mail to my email([email protected]). |
Hi @gcourtemanche !
|
@hank121314 yes, it does have intersection types! |
The latest commit at developer branch solved intersection types issue! Please try it. |
@hank121314 I can't find the developer branch :( |
Forget to tell I commit to my own fork. Here:https://github.com/hank121314/eslint-plugin-react/tree/develop |
The error is gone but another error appeared: Using this code:
If I remove the optional to |
This error appeared because of rule(require-default-props). |
@hank121314 I only get the error when I'm using your branch |
The error should display.
|
Great, thank you for you help @hank121314 ! :) |
Anytime 😄 . |
…ript props interface extension and TSTypeAliasDeclaration Fixes jsx-eslint#2654. Fixes jsx-eslint#2719. Fixes jsx-eslint#2703.
…ript props interface extension and TSTypeAliasDeclaration Fixes jsx-eslint#2654. Fixes jsx-eslint#2719. Fixes jsx-eslint#2703.
…ript props interface extension and TSTypeAliasDeclaration Fixes jsx-eslint#2654. Fixes jsx-eslint#2719. Fixes jsx-eslint#2703.
I'm trying to update 7.20.0 to 7.20.3, but I have new false positive errors for components that can return
null
.This is telling me
'number' is missing in props validationeslintreact/prop-types
:But this is fine:
The text was updated successfully, but these errors were encountered: