Skip to content

Commit

Permalink
getKeyValue should account for variance syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhyndman committed Nov 26, 2016
1 parent f84642d commit 30b6e00
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,11 @@ module.exports = {
*/
function getKeyValue(node) {
if (node.type === 'ObjectTypeProperty') {
var tokens = context.getFirstTokens(node, 1);
return tokens[0].value;
var tokens = context.getFirstTokens(node, 2);
return (tokens[0].value === '+' || tokens[0].value === '-'
? tokens[1].value
: tokens[0].value
);
}
var key = node.key || node.argument;
return key.type === 'Identifier' ? key.name : key.value;
Expand Down

0 comments on commit 30b6e00

Please sign in to comment.