Rules
no-missing-button-type
Enforces an explicit 'type' attribute for 'button' elements.
Full Name in eslint-plugin-react-dom
react-dom/no-missing-button-typeFull Name in @eslint-react/eslint-plugin
@eslint-react/dom/no-missing-button-typeFeatures
🔧
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.
Common Violations
Invalid
function MyComponent() {
return <button>Click me</button>;
// ^^^ Missing 'type' attribute on button component.
}Valid
function MyComponent() {
return <button type="button">Click me</button>;
}Resources
Further Reading
See Also
react-dom/no-missing-iframe-sandbox
Enforces an explicitsandboxattribute foriframeelements.