-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: check to ensure forbid-prop-types throws only off of React.PropTypes #2739
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
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks! We'll need some regression tests.
An issue was raised where using an alternative library with a similar syntax (in this case Yup) resulted in the rule `forbid-prop-types` stating that `Yup.array()` was an invalid proptype. Adding another check to ensure pragma is used and the check is off of `PropTypes`, removes the false erorrs thrown up when using those other libraries. Signed-off-by: Josh Kelly <josh@codecog.dev>
PropTypes
PropTypes
PropTypes
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.
We'd still need some regression tests to prove the fix is working.
@@ -170,6 +172,7 @@ module.exports = { | |||
CallExpression(node) { | |||
if ( | |||
node.arguments.length > 0 | |||
&& `${pragma}.PropTypes` |
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.
should this be comparing this string to anything? otherwise it's just a noop and could be deleted.
&& `${pragma}.PropTypes` | |
&& node.callee.object.name === `${pragma}.PropTypes` |
@nonewcode are you still interested in completing this PR? |
An issue was raised where using an alternative library with a similar syntax (in this case Yup) resulted in the rule
forbid-prop-types
stating thatYup.array()
was an invalid proptype. Adding another check to ensure pragma is used and the check is off ofPropTypes
, removes the false erorrs thrown up when using those other libraries.