Skip to content

Commit

Permalink
Fix jsx-handler-names crash with arrays (fixes #340)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Nov 30, 2015
1 parent db6f841 commit 2204feb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rules/jsx-handler-names.js
Expand Up @@ -26,8 +26,8 @@ module.exports = function(context) {
function rebuildPropValue(valueNode) {
var valueNodeObject = valueNode.object;
var subObjectType = valueNodeObject.object ? valueNodeObject.object.type : '';
var propertyName = valueNodeObject.property ? valueNodeObject.property.name : '';
var propValue = valueNode.property ? valueNode.property.name : '';
var propertyName = valueNodeObject.property && valueNodeObject.property.name ? valueNodeObject.property.name : '';
var propValue = valueNode.property && valueNode.property.name ? valueNode.property.name : '';

if (propertyName.length) {
propValue = propertyName + '.' + propValue;
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/rules/jsx-handler-names.js
Expand Up @@ -52,6 +52,13 @@ ruleTester.run('jsx-handler-names', rule, {
ecmaFeatures: {
jsx: true
}
}, {
code: [
'<TestComponent shouldDisplay={arr[0].prop} />'
].join('\n'),
ecmaFeatures: {
jsx: true
}
}],

invalid: [{
Expand Down

0 comments on commit 2204feb

Please sign in to comment.