Skip to content

Commit faaa823

Browse files
committed
Add support for ES7 bind operator to jsx-handler-names (fixes #630)
1 parent 4418534 commit faaa823

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/rules/jsx-handler-names.js

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

2828
var propKey = typeof node.name === 'object' ? node.name.name : node.name;
29-
var propValue = sourceCode.getText(node.value.expression).replace(/^this\./, '');
29+
var propValue = sourceCode.getText(node.value.expression).replace(/^this\.|.*::/, '');
3030

3131
if (propKey === 'ref') {
3232
return;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ ruleTester.run('jsx-handler-names', rule, {
7878
eventHandlerPropPrefix: 'on'
7979
}],
8080
parserOptions: parserOptions
81+
}, {
82+
code: [
83+
'<TestComponent onChange={props::handleChange} />'
84+
].join('\n'),
85+
parser: 'babel-eslint'
8186
}],
8287

8388
invalid: [{
@@ -98,5 +103,11 @@ ruleTester.run('jsx-handler-names', rule, {
98103
].join('\n'),
99104
parserOptions: parserOptions,
100105
errors: [{message: 'Handler function for onChange prop key must begin with \'handle\''}]
106+
}, {
107+
code: [
108+
'<TestComponent onChange={props::onChange} />'
109+
].join('\n'),
110+
parser: 'babel-eslint',
111+
errors: [{message: 'Handler function for onChange prop key must begin with \'handle\''}]
101112
}]
102113
});

0 commit comments

Comments
 (0)