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

rule proposal: forbid element/components #887

Closed
kentor opened this issue Oct 5, 2016 · 5 comments
Closed

rule proposal: forbid element/components #887

kentor opened this issue Oct 5, 2016 · 5 comments

Comments

@kentor
Copy link
Contributor

kentor commented Oct 5, 2016

It would be useful to have a rule that forbids elements/components from a list of names.

In my organization we want to ban using <button> in favor of a custom <Button> component that is simply:

Button = (props) => <button type="button" {...props}>{props.children}</button>

The reason is to prevent a bug in IE where pressing enter on an input could trigger the click event on a button even when they don't share a parent form if the button has type="submit" (default if no type). (https://www.tjvantoll.com/2013/05/22/why-are-enter-keypresses-clicking-my-buttons-in-ie/)

@kentor kentor changed the title forbid element/components rule proposal: forbid element/components Oct 5, 2016
@ljharb
Copy link
Member

ljharb commented Oct 5, 2016

While a generic rule could be useful, I think a specific rule that requires that <button> have an explicit "type" defined would also be helpful.

@kentor
Copy link
Contributor Author

kentor commented Oct 5, 2016

I can see that being useful as well but it seems like those rules have different use cases and they can both exist at the same time.

The reason I chose to use a custom Button component instead of enforcing a type prop was because

  1. I simply think type=submit is a bad default, and rather it be type=button. but specs are specs
  2. we're enforcing 80 characters per line, so not having to specify the type is a big win

@ljharb
Copy link
Member

ljharb commented Oct 5, 2016

Totally, I think adding both is good.

@kentor
Copy link
Contributor Author

kentor commented Oct 5, 2016

Great! I can start on forbidding elements

@alexzherdev
Copy link
Contributor

I think button-has-type plus #890 address both of these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants