Skip to content

Commit

Permalink
Merge pull request #321 from dapetcu21/master
Browse files Browse the repository at this point in the history
Fix crash on incomplete class property declaration (fixes #317)
  • Loading branch information
yannickcr committed Nov 18, 2015
2 parents e31b735 + c223c2d commit 25e05b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions lib/rules/jsx-sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ module.exports = function(context) {
// (babel-eslint does not expose property name so we have to rely on tokens)
if (node.type === 'ClassProperty') {
var tokens = context.getFirstTokens(node, 2);
if (tokens[0].value === 'propTypes' || tokens[1].value === 'propTypes') {
return true;
}
return false;
return (tokens[0] && tokens[0].value === 'propTypes') ||
(tokens[1] && tokens[1].value === 'propTypes');
}

return Boolean(
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/sort-comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ module.exports = Components.detect(function(context, components) {
// (babel-eslint does not expose property name so we have to rely on tokens)
if (node.type === 'ClassProperty') {
var tokens = context.getFirstTokens(node, 2);
return tokens[1].type === 'Identifier' ? tokens[1].value : tokens[0].value;
return tokens[1] && tokens[1].type === 'Identifier' ? tokens[1].value : tokens[0].value;
}

return node.key.name;
Expand Down

0 comments on commit 25e05b8

Please sign in to comment.