jsx-button-has-type Note: this rule is included in the following rule sets: recommended, react, jsx, fresh.
Enable the full set in ende.json:
{
"lint": {
"rules": {
"tags": ["recommended"] // ...or "react", "jsx", "fresh"
}
}
}Enable the full set using the Ende CLI:
ende lint --rules-tags=recommended
# or ...
ende lint --rules-tags=react
# or ...
ende lint --rules-tags=jsx
# or ...
ende lint --rules-tags=freshThis rule can be explicitly included in or excluded from the rules present in the current tag by adding it to the include or exclude array in ende.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> ;