diff --git a/lib/rules/require-default-props.js b/lib/rules/require-default-props.js index 9462a10652..cfd28679fc 100644 --- a/lib/rules/require-default-props.js +++ b/lib/rules/require-default-props.js @@ -142,7 +142,7 @@ module.exports = { return props.map(function(property) { return { - name: property.key.name, + name: property.key.name || property.key.value, isRequired: isRequiredPropType(property.value), node: property }; diff --git a/tests/lib/rules/require-default-props.js b/tests/lib/rules/require-default-props.js index c3c9f6db6a..e3ef2ebc8b 100644 --- a/tests/lib/rules/require-default-props.js +++ b/tests/lib/rules/require-default-props.js @@ -1805,6 +1805,24 @@ ruleTester.run('require-default-props', rule, { errors: [{ message: 'propType "name" is not required, but has no corresponding defaultProp declaration.' }] + }, + { + code: [ + 'class Hello extends React.Component {', + ' static get propTypes() {', + ' return {', + ' \'first-name\': PropTypes.string', + ' };', + ' }', + ' render() {', + ' return