Try @eslint-react/kit@beta
logoESLint React

no-missing-button-type

Enforces an explicit 'type' attribute for 'button' elements.

Full Name in eslint-plugin-react-dom

react-dom/no-missing-button-type

Full Name in @eslint-react/eslint-plugin

@eslint-react/dom-no-missing-button-type

Features

🔧

Presets

strict strict-typescript strict-type-checked

Rule Details

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behavior you want inside a React application.

Allowed button types are submit, button, or reset.

Examples

Rendering a <button> without an explicit type

A button without a type attribute defaults to submit, which can unintentionally submit forms.

// Problem: missing explicit type; defaults to submit.
function MyComponent() {
  return <button>Click me</button>;
  //     ^^^ Missing 'type' attribute on button component.
}
// Recommended: explicitly declare the button type.
function MyComponent() {
  return <button type="button">Click me</button>;
}

Versions

Resources

Further Reading


See Also

On this page