diff --git a/lib/rules/jsx-sort-prop-types.js b/lib/rules/jsx-sort-prop-types.js index 3b5c2118f4..8149847afb 100644 --- a/lib/rules/jsx-sort-prop-types.js +++ b/lib/rules/jsx-sort-prop-types.js @@ -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( diff --git a/lib/rules/sort-comp.js b/lib/rules/sort-comp.js index cede34d850..9ffbbd6f8a 100644 --- a/lib/rules/sort-comp.js +++ b/lib/rules/sort-comp.js @@ -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;