-
Notifications
You must be signed in to change notification settings - Fork 49
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
Handle explicit proptypes and default props #196
Handle explicit proptypes and default props #196
Conversation
Wow, this looks great! It's a bit hard to review the snapshots with multiple tests in one file. Could you please split them up?
I don't think I want a config option for this. If you're defining a props flow type, and propTypes, merging seems like the correct behavior. If you don't want this, then you can disable the plugin for that file (
Same as This plugin is a small part of your tooling, so adding config options is a high cost to users. Other contributors have also been against adding config options. |
Great! I'll remove config options, agree. Also, happy to split up tests - do you prefer one snap shot spec per file? Theres a few test files with several specs, so just want to confirm that before creating a bunch of files. |
Yeah, one snapshot per test file is best. |
Updated, let me know if any questions / suggestions. |
Sorry for the delay. Published as 24.0.0. Thanks! |
Great project! This PR combines 2 things my company needed for our codebase. I included as separate commits under a single PR for ease of initial discussion. I'm happy to split it up, or drop parts, based on feedback.
Issue 1: Explicitly defined proptypes (9fc0875)
X.proptypes = {}; X.propTypes = {};
), if a component also defines prop types.mergeExplicitPropTypes
Issue 2: Default props optional (e968b5c)
defaultProps
for a component, it is not a flow error to call that component without passing passing in props manually (flow picks up on the defaultProps). However, this plugin marks the propTypes asisRequired
, regardless ofdefaultProps
. This can result in discrepancies based on falsy values.defaultPropsOptional
.Issue 3: Anonymous classes in hocs: This was fixed by 20.1.0 as well (thanks!), so I undid my changes, but left in my specs, if helpful.