react/button-has-type Restriction
What it does
Enforces explicit type
attribute for all the button
HTML elements.
Why is this bad?
The default value of type
attribute for button
HTML element is "submit"
which is often not the desired behavior and may lead to unexpected page reloads.
Example
Examples of incorrect code for this rule:
jsx
<button />
<button type="foo" />
Examples of correct code for this rule:
jsx
<button type="button" />
<button type="submit" />
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny react/button-has-type
json
{
"rules": {
"react/button-has-type": "error"
}
}