Skip to content

Button tags require type. #894

Closed
Closed
@shadow7412

Description

@shadow7412

Please describe what the rule should do:

All <button> tags require the type to be set.
What category should the rule belong to?

  • Enforces code style
  • Warns about a potential error
  • Suggests an alternate way of doing something
  • Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

<button>Test</button>
<button class="btn btn-danger">Delete</button>

Additional context

Forgetting the type attribute on a button defaults it to being a submit type. This is nearly never what is intended, especially in your average one-page application.

type="button" stops the webpage from submitting the form, instead allowing the @click handler to work without the page reloading soon after.

type="submit" can be used explicitly to allow the default behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions