Skip to content

Commit

Permalink
Fix jsx-handler-names regex (fixes #425)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Feb 15, 2016
1 parent 6643f87 commit 49eedb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rules/jsx-handler-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module.exports = function(context) {
var eventHandlerPrefix = configuration.eventHandlerPrefix || 'handle';
var eventHandlerPropPrefix = configuration.eventHandlerPropPrefix || 'on';

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

return {
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/jsx-handler-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ ruleTester.run('jsx-handler-names', rule, {
'<TestComponent ref={this.somethingRef} />'
].join('\n'),
parserOptions: parserOptions
}, {
code: [
'<TestComponent test={this.props.content} />'
].join('\n'),
options: [{
eventHandlerPrefix: 'on',
eventHandlerPropPrefix: 'on'
}],
parserOptions: parserOptions
}],

invalid: [{
Expand Down

0 comments on commit 49eedb0

Please sign in to comment.