Skip to content

Commit f1a5fe2

Browse files
committed
Ignore ref in jsx-handler-names (fixes #375)
1 parent be33738 commit f1a5fe2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/rules/jsx-handler-names.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = function(context) {
1616

1717
var EVENT_HANDLER_REGEX = new RegExp('^((props\.' + eventHandlerPropPrefix + ')'
1818
+ '|((.*\.)?' + eventHandlerPrefix + ')).+$');
19-
var PROP_EVENT_HANDLER_REGEX = new RegExp('^' + eventHandlerPropPrefix + '.+$');
19+
var PROP_EVENT_HANDLER_REGEX = new RegExp('^(' + eventHandlerPropPrefix + '.+|ref)$');
2020

2121
return {
2222
JSXAttribute: function(node) {

tests/lib/rules/jsx-handler-names.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ ruleTester.run('jsx-handler-names', rule, {
5959
'<TestComponent onChange={props.onChange} />'
6060
].join('\n'),
6161
parserOptions: parserOptions
62+
}, {
63+
code: [
64+
'<TestComponent ref={this.handleRef} />'
65+
].join('\n'),
66+
parserOptions: parserOptions
6267
}],
6368

6469
invalid: [{

0 commit comments

Comments
 (0)