-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix #884 #914
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 #884 #914
Conversation
@@ -1277,6 +1277,9 @@ ruleTester.run('prop-types', rule, { | |||
' return names.map((name) => {', | |||
' return <div>{name}</div>;', | |||
' });', | |||
'}', | |||
'Hello.propTypes = {', | |||
' names: React.PropTypes.string', |
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.
Here Hello
is not a component (it returns an Array, so no propTypes
should be specified)
any update here? would be happy to help out if needed. |
Sorry, I never found the time to address the change requests and to see this through to merging. And I probably won't any time soon. If you want to completely take this over and see it through to merging, feel free! |
sure! |
Is there something I can do to let you "take over" this PR? Or maybe should I close this one and let you open another one? |
yeah, that makes the most sense to me. |
The most straightforward way of fixing #884 would be to add a third condition to
isPropTypesUsage
that checks if it's anextProps
orprevProps
in a lifecycle method. If I did this, then I'd also have to addnextProps
andprevProps
toDIRECT_PROPS_REGEX
. I didn't want to do that because it duplicates logic betweenDIRECT_PROPS_REGEX
andisPropAttributeName
.So this PR removes the need for
DIRECT_PROPS_REGEX
.The main idea is that before this PR, the
MemberExpression
callback caught direct access (props.foo
) and ThisExpression access (this.props.foo
) at different "levels" in the AST. This meant thatgetPropertyName
had to have some logic to fix them up to be on the same level. I added aIdentifer
callback that catches direct access at the same level asMemberExpression
catches ThisExpression access so thatgetPropertyName
no longer needs that logic.This change uncovered something that I think is a bug in Components.js that made one of the existing no-unused-prop-types tests start failing, so I fixed that too.