Rules
no-missing-button-type
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
domrecommendedrecommended-typescriptrecommended-type-checked
Description
Enforces explicit type attribute for button elements.
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 behaviour that you want inside a React application.
Allowed button types are: submit, button or reset.
Examples
Failing
import React from "react";
function MyComponent() {
return <button>Click me</button>;
// ^^^^^^^^^^^^^^^^^^^^^^^^^
// - Missing 'type' attribute on button component.
}Passing
import React from "react";
function MyComponent() {
return <button type="button">Click me</button>;
}Implementation
Further Reading
See Also
no-missing-iframe-sandbox
Enforces explicitsandboxattribute foriframeelements.