# svelte/button-has-type

disallow usage of button without an explicit type attribute

# 📖 Rule Details

This rule aims to warn if no type or an invalid type is used on a button type attribute.

<script>
  /* eslint svelte/button-has-type: "error" */
</script>

<!-- ✓ GOOD -->
<button type="button">Hello World</button>
<button type="submit">Hello World</button>
<button type="reset">Hello World</button>

<!-- ✗ BAD -->
Missing an explicit type attribute for button. (svelte/button-has-type)
<button>
Hello World</button>
<button
A value must be set for button type attribute. (svelte/button-has-type)
type=""
>Hello World</button>
<button
foo is an invalid value for button type attribute. (svelte/button-has-type)
type="foo"
>Hello World</button>

# 🔧 Options

{
  "svelte/button-has-type": [
    "error",
    {
      "button": true,
      "submit": true,
      "reset": true
    }
  ]
}
  • button<button type="button"></button>
    • true (default) … allow value button.
    • false … disallow value button.
  • submit<button type="submit"></button>
    • true (default) … allow value submit.
    • false … disallow value submit.
  • reset<button type="reset"></button>
    • true (default) … allow value reset.
    • false … disallow value reset.

# 🚀 Version

This rule was introduced in eslint-plugin-svelte v0.0.4

# 🔍 Implementation