html-eslint v0.69.0

require-button-type

This rule enforces that button elements include a valid type attribute: "button", "submit", or "reset"

How to use

.eslintrc.js
module.exports = {
  rules: {
    "@html-eslint/require-button-type": "error",
  },
};

Rule Details

Note: When a button has a template expression in attribute position, the rule still reports a missing type but does not auto-fix it, since the expression may already render one.

Examples of incorrect code for this rule:

<button></button>
<button type="invalid"></button>

Examples of correct code for this rule:

<button type="submit"></button>
<button type="button"></button>
<button type="reset"></button>

Further Reading

  1. HTML spec - the button element