Skip to content

Commit

Permalink
Fix invalid class property handling in jsx-sort-prop-types (fixes #129)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Jun 26, 2015
1 parent 338e530 commit b1e1f40
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 @@ -65,7 +65,7 @@ module.exports = function(context) {

return {
ClassProperty: function(node) {
if (isPropTypesDeclaration(node) && node.value.type === 'ObjectExpression') {
if (isPropTypesDeclaration(node) && node.value && node.value.type === 'ObjectExpression') {
checkSorted(node.value.properties);
}
},
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 @@ -176,6 +176,21 @@ eslintTester.addRuleTest('lib/rules/jsx-sort-prop-types', {
args: [1, {
ignoreCase: true
}]
}, {
// Invalid code, should not be validated
code: [
'class Component extends React.Component {',
' propTypes: {',
' a: React.PropTypes.any,',
' c: React.PropTypes.any,',
' b: React.PropTypes.any',
' }',
' render() {',
' return <div />;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit b1e1f40

Please sign in to comment.