Skip to content

Commit 3371be2

Browse files
committed
Really ignore ref in jsx-handler-names (fixes #396)
1 parent 4da92df commit 3371be2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/rules/jsx-handler-names.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ module.exports = function(context) {
2727
var propKey = typeof node.name === 'object' ? node.name.name : node.name;
2828
var propValue = context.getSource(node.value.expression).replace(/^this\./, '');
2929

30+
if (propKey === 'ref') {
31+
return;
32+
}
33+
3034
var propIsEventHandler = PROP_EVENT_HANDLER_REGEX.test(propKey);
3135
var propFnIsNamedCorrectly = EVENT_HANDLER_REGEX.test(propValue);
3236

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ ruleTester.run('jsx-handler-names', rule, {
6464
'<TestComponent ref={this.handleRef} />'
6565
].join('\n'),
6666
parserOptions: parserOptions
67+
}, {
68+
code: [
69+
'<TestComponent ref={this.somethingRef} />'
70+
].join('\n'),
71+
parserOptions: parserOptions
6772
}],
6873

6974
invalid: [{

0 commit comments

Comments
 (0)