Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1686 - jsx-handler-names: false positive when handler name begins with number #1689

Merged
merged 1 commit into from Sep 20, 2020

Conversation

jsphstls
Copy link
Contributor

Updated unit test and EVENT_HANDLER_REGEX regex.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me.

Could you also add some invalid test cases that use numbers?

@jsphstls
Copy link
Contributor Author

I adjusted the regex so that a capital letter is still required at some point after the word "handle" and added more test cases to demonstrate that minimum requirement.

errors: [{message: 'Handler function for onChange prop key must begin with \'handle\''}]
}, {
code: '<TestComponent onChange={this.handle4change} />',
errors: [{message: 'Handler function for onChange prop key must begin with \'handle\''}]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, we should probably change the error message to add " and be in camelCase", otherwise this one's pretty confusing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the error message to be more specific and removed the handleC test case that does pass, but should not be considered valid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the test wrongly passes, we should move it to the "invalid" section, even if it's commented out for now.

@ljharb ljharb added the bug label Sep 20, 2020
@ljharb ljharb merged commit ac49944 into jsx-eslint:master Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants