Skip to content

Commit

Permalink
Merge pull request #409 from alitaheri/fix-408
Browse files Browse the repository at this point in the history
Fix jsx-sort-prop-types issue with custom propTypes (fixes #408)
  • Loading branch information
yannickcr committed Jan 24, 2016
2 parents d7c3ad2 + eede741 commit c1ce38b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/jsx-sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = function(context) {
}

function getValueName(node) {
return node.value.property.name;
return node.value.property && node.value.property.name;
}

function isCallbackPropName(propName) {
Expand Down
15 changes: 15 additions & 0 deletions tests/lib/rules/jsx-sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ ruleTester.run('jsx-sort-prop-types', rule, {
requiredFirst: true
}],
parserOptions: parserOptions
}, {
code: [
'class First extends React.Component {',
' render() {',
' return <div />;',
' }',
'}',
'First.propTypes = {',
' fooRequired: MyPropType,',
'};'
].join('\n'),
options: [{
requiredFirst: true
}],
parserOptions: parserOptions
}, {
code: [
'class First extends React.Component {',
Expand Down

0 comments on commit c1ce38b

Please sign in to comment.