Skip to content

buttonTypes

Reports button elements without an explicit type attribute.

✅ This rule is included in the jsx logical and logicalStrict presets.

Button elements without an explicit type attribute default to type="submit", which can cause unintended form submissions. This rule requires that all <button> elements have an explicit type attribute set to one of the valid values: "button", "submit", or "reset".

Specifying an explicit type makes the button’s behavior clear and prevents accidental form submissions.

CE6buttCsp ansty="le--0:#D6DEEB;--1:#403F">53Click sp>CA<E6buttCd ivclassNa="meco">d>d>d>CE6buttCB0onCliA3<4{sp ansty="le--0:#D6DEEB;--1:#403F">53handleCli3<4}sp ansty="le--0:#7FDBCA;--1:#8844">Asp ansty="le--0:#D6DEEB;--1:#403F">53Submsp>CA<E6buttCd ivclassNa="meco">d>d>d>CE6buttCB0tyA1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Dinval1<1"sp ansty="le--0:#7FDBCA;--1:#8844">Asp ansty="le--0:#D6DEEB;--1:#403F">53Clisp>CA<E6buttCd ivclassNa="meco">d>d>d>
<44AE spans="tyle--0:#7F">DECE6buD61B04<4AE= spans="tyle--0:#D9F5DD;--1:#11">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dbu1<111" spans="tyle--0:#7FDBCA;--1:#88">4<4AE> spans="tyle--0:#D6DEEB;--1:#40">3F53Clic><44AE spans="tyle--0:#7F">DBECE6buD<>di vdivclass="Nameexpressive-"><44AE spans="tyle--0:#7F">DECE6buD61B04<4AE= spans="tyle--0:#D9F5DD;--1:#11">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dsu1<111" spans="tyle--0:#7FDBCA;--1:#88">4<4AE> spans="tyle--0:#D6DEEB;--1:#40">3F53Submit >
<44AE spans="tyle--0:#7F">DBECE6buD
di><>di vdivclass="Nameexpressive-"><44AE spans="tyle--0:#7F">DECE6buD61B04<4AE= spans="tyle--0:#D9F5DD;--1:#11">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dr1<111" spans="tyle--0:#7FDBCA;--1:#88">4<4AE> spans="tyle--0:#D6DEEB;--1:#40">3F53Reset >
<44AE spans="tyle--0:#7F">DBECE6buD
di>

If your codebase exclusively uses buttons in forms where the default submit behavior is never a concern, you might choose to disable this rule. However, it’s generally recommended to be explicit about button types for clarity and maintainability.