Skip to content

Commit

Permalink
Really ignore ref in jsx-handler-names (fixes #396)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Jan 16, 2016
1 parent 4da92df commit 3371be2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rules/jsx-handler-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module.exports = function(context) {
var propKey = typeof node.name === 'object' ? node.name.name : node.name;
var propValue = context.getSource(node.value.expression).replace(/^this\./, '');

if (propKey === 'ref') {
return;
}

var propIsEventHandler = PROP_EVENT_HANDLER_REGEX.test(propKey);
var propFnIsNamedCorrectly = EVENT_HANDLER_REGEX.test(propValue);

Expand Down
5 changes: 5 additions & 0 deletions tests/lib/rules/jsx-handler-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ ruleTester.run('jsx-handler-names', rule, {
'<TestComponent ref={this.handleRef} />'
].join('\n'),
parserOptions: parserOptions
}, {
code: [
'<TestComponent ref={this.somethingRef} />'
].join('\n'),
parserOptions: parserOptions
}],

invalid: [{
Expand Down

0 comments on commit 3371be2

Please sign in to comment.