jsx-button-has-type
NOTE: this rule is included the following rule sets:
recommended
react
jsx
fresh
Enable full set in
deno.json
:{ "lint": { "tags": ["recommended"] // ...or "react", "jsx", "fresh" } }
Enable full set using the Deno CLI:
deno lint --tags=recommended # or ... deno lint --tags=react # or ... deno lint --tags=jsx # or ... deno lint --tags=fresh
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>;