only happened on the functional component, class component it is work.
version
"eslint": "^4.8.0",
"eslint-config-airbnb": "^16.0.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0",
error message
Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
at checkValidPropObject (/Users/yutin/Studio/tmot/hitmot/node_modules/eslint-plugin-react/lib/rules/no-typos.js:76:15)
at checkValidProp (/Users/yutin/Studio/tmot/hitmot/node_modules/eslint-plugin-react/lib/rules/no-typos.js:65:11)
at node.properties.forEach.prop (/Users/yutin/Studio/tmot/hitmot/node_modules/eslint-plugin-react/lib/rules/no-typos.js:77:41)
at Array.forEach (native)
at checkValidPropObject (/Users/yutin/Studio/tmot/hitmot/node_modules/eslint-plugin-react/lib/rules/no-typos.js:77:25)
at reportErrorIfClassPropertyCasingTypo (/Users/yutin/Studio/tmot/hitmot/node_modules/eslint-plugin-react/lib/rules/no-typos.js:85:9)
at MemberExpression (/Users/yutin/Studio/tmot/hitmot/node_modules/eslint-plugin-react/lib/rules/no-typos.js:135:11)
at listeners.(anonymous function).forEach.listener (/Users/yutin/Studio/tmot/hitmot/node_modules/eslint/lib/util/safe-emitter.js:47:58)
at Array.forEach (native)
at Object.emit (/Users/yutin/Studio/tmot/hitmot/node_modules/eslint/lib/util/safe-emitter.js:47:38)
sample code
function Component({ data }) {
return (<View />);
}
Component.displayName = 'Channel';
Component.propTypes = {
data: PropTypes.shape(), // <= this line
};
Component.defaultProps = {
data: {},
};
export default Component;
Is the error fixed if you add {} inside the shape call?
oh!! thank you. {} is required. add {} inside will be fixed.
I've never seen shape used without an object literal, but React doesn't require it, and regardless, we shouldn't crash on it.
+1 to don't fail on this
Yup... this got me too.
Once the bug is fixed... perhaps a new rule for no-undefined-shape?
Fixed in #1504.
"eslint-config-airbnb": "17.1.0",
"eslint-config-prettier": "3.3.0",
"eslint-plugin-flowtype": "3.2.0",
"eslint-plugin-immutable": "1.0.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-prettier": "3.0.1",
"eslint-plugin-react": "7.12.3",
[Error - 11:14:02 PM] TypeError: Cannot read property 'type' of undefined
at resolveSuperParameterPropsType (***/node_modules/eslint-plugin-react/lib/util/propTypes.js:574:20)
at Object.ClassDeclaration (***/node_modules/eslint-plugin-react/lib/util/propTypes.js:610:39)
at updatedRuleInstructions.(anonymous function) (***/node_modules/eslint-plugin-react/lib/util/Components.js:706:43)
@FDiskas please file a new issue; commenting on a closed issue isn't going to help anything get fixed.
Most helpful comment
I've never seen
shapeused without an object literal, but React doesn't require it, and regardless, we shouldn't crash on it.