jsx-button-has-type
NOTE: this rule is included the following rule sets:
recommendedreactjsxfreshEnable full set in
deno.json:{
"lint": {
"rules": {
"tags": ["recommended"] // ...or "react", "jsx", "fresh"
}
}
}Enable full set using the Deno CLI:
deno lint --rules-tags=recommended # or ... deno lint --rules-tags=react # or ... deno lint --rules-tags=jsx # or ... deno lint --rules-tags=fresh
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include or exclude array in deno.json:{
"lint": {
"rules": {
"include": ["jsx-button-has-type"],
"exclude": ["jsx-button-has-type"]
}
}
}Enforce <button> elements to have a type attribute. If a <button> is
placed inside a <form> element it will act as a submit button by default which
can be unexpected.
Invalid:
const btn = <button>click me</button>;
const btn = <button type="2">click me</button>;
Valid:
const btn = <button type="button">click me</button>;
const btn = <button type="submit">click me</button>;
const btn = <button type={btnType}>click me</button>;
const btn = <button type={condition ? "button" : "submit"}>click me</button>;