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

Add a rule enforcing explicit "type" attributes for buttons #1525

Merged
merged 3 commits into from Nov 11, 2017
Merged

Add a rule enforcing explicit "type" attributes for buttons #1525

merged 3 commits into from Nov 11, 2017

Conversation

Hypnosphi
Copy link
Contributor

By default, button elements have type="submit", which usually isn't what you actually want. This rule enforces the button type to be explicit

See also: https://github.com/evcohen/eslint-plugin-jsx-a11y/issues/186#issuecomment-283727911

@Hypnosphi
Copy link
Contributor Author

I'm open to renaming it BTW, maybe jsx-explicit-button-type would be more... explicit =D

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.

This should also validate that the type is one of submit, button, or reset.

Also, it would be ideal to configure each separately, since Airbnb would always forbid using reset, which is horrific for UX.

Can this perhaps not just apply to jsx, and also apply to React.createElement?

@ljharb ljharb added the new rule label Nov 9, 2017
@ljharb
Copy link
Member

ljharb commented Nov 9, 2017

As for the name, button-has-type might work?

@Hypnosphi
Copy link
Contributor Author

Can this perhaps not just apply to jsx, and also apply to React.createElement?

Are there some examples of rules that check both JSX and createElement?

@petersendidit
Copy link
Contributor

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.

Thanks, this LGTM!

@ljharb
Copy link
Member

ljharb commented Nov 9, 2017

I'll give this a day, and then merge if there's no objections.

@ljharb ljharb merged commit 8795fde into jsx-eslint:master Nov 11, 2017
jzaefferer added a commit to sevenval/eslint-plugin-react that referenced this pull request Nov 13, 2017
Looks like a copy&pasta error.

Ref jsx-eslint#1525
jzaefferer added a commit to sevenval/eslint-plugin-react that referenced this pull request Nov 13, 2017
Looks like a copy&pasta error.

Ref jsx-eslint#1525
@nwoltman nwoltman mentioned this pull request Nov 19, 2017
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

3 participants