Skip to content

Commit

Permalink
[Fix] jsx-handler-names: handle whitespace
Browse files Browse the repository at this point in the history
Fixes #2785
  • Loading branch information
AriPerkkio committed Sep 6, 2020
1 parent de2ec66 commit a2e7a39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rules/jsx-handler-names.js
Expand Up @@ -121,6 +121,7 @@ module.exports = {
const expression = node.value.expression;
const propValue = context.getSourceCode()
.getText(checkInlineFunction && isInlineHandler(node) ? expression.body.callee : expression)
.replace(/\s*/g, '')
.replace(/^this\.|.*::/, '');

if (propKey === 'ref') {
Expand Down
14 changes: 14 additions & 0 deletions tests/lib/rules/jsx-handler-names.js
Expand Up @@ -32,6 +32,20 @@ ruleTester.run('jsx-handler-names', rule, {
code: '<TestComponent onChange={this.handleChange} />'
}, {
code: '<TestComponent onChange={this.props.onChange} />'
},
{
code: `<TestComponent
onChange={
this
.handleChange
} />`
}, {
code: `<TestComponent
onChange={
this
.props
.handleChange
} />`
}, {
code: '<TestComponent onChange={handleChange} />',
options: [{
Expand Down

0 comments on commit a2e7a39

Please sign in to comment.