-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Crash in forbid-prop-types #230
Comments
I'm also unfortunately not sure what code exactly is triggering this. It's coming from somewhere in our |
Thanks for the report, I'll try to fix this ASAP. It would be a great help for us if you can track down the code responsible for the crash, maybe by running ESLint on one directory at a time until you find the file that trigger this error ? |
I think I've figured it out. We're destructuring React to get {PropTypes}, so the propTypes that triggers the crash looks like:
I would guess that the plugin expects only React.PropTypes, which causes the error. |
Then again, maybe not. Changing to React.PropTypes did not seem to fix it. |
I'm getting the same issue, this code makes it crash : static propTypes = {
retailer: PropTypes.instanceOf(Map).isRequired,
requestRetailer: PropTypes.func.isRequired
} this code doesn't :
|
Not entirely fixed it seems.
|
Fix crash with destructured PropTypes (fixes #230)
Found another example to contribute. This doesn't work: var optionPropType = {
value: React.PropTypes.string.isRequired,
label: React.PropTypes.string.isRequired
};
var DropdownView = React.createClass({
propTypes: {
widthNamed: Dropdown.propTypes.width,
optionPrompt: React.PropTypes.string,
selected: optionPropType,
options: React.PropTypes.arrayOf(React.PropTypes.shape(optionPropType))
}
}); Then, I noticed that I was actually passing in a plain object to var optionPropType = React.PropTypes.shape({
value: React.PropTypes.string.isRequired,
label: React.PropTypes.string.isRequired
});
var DropdownView = React.createClass({
propTypes: {
widthNamed: Dropdown.propTypes.width,
optionPrompt: React.PropTypes.string,
selected: optionPropType,
options: React.PropTypes.arrayOf(optionPropType)
}
}); EDIT: var DropdownView = React.createClass({
propTypes: {
widthNamed: Dropdown.propTypes.width,
optionPrompt: React.PropTypes.string,
selected: React.PropTypes.shape({
value: React.PropTypes.string.isRequired,
label: React.PropTypes.string.isRequired
}),
options: React.PropTypes.arrayOf(Dropdown.propTypes.option)
},
}); I guess the issue is just with referencing objects defined in the same file? |
I'm getting a crash on line 65 of forbid-prop-types.js.
Cannot read property 'name' of undefined
. My guess is that the line above (declaration.value = declaration.value.object;
) is storing an object without a property value, which then crashes. It could probably be fixed by just doing an existence check, but I'm not entirely sure that there isn't an upstream issue that's the root cause.The text was updated successfully, but these errors were encountered: