# svelte/no-not-function-handler

disallow use of not function in event handler

  • βš™οΈ This rule is included in "plugin:svelte/recommended".

# πŸ“– Rule Details

This rule reports where you used not function value in event handlers.
If you use a non-function value for the event handler, it event handler will not be called. It’s almost always a mistake. You may have written a lot of unnecessary curly braces.

<script>
  /* eslint svelte/no-not-function-handler: "error" */
  function foo() {
    /*  */
  }
  const bar = 42;
</script>

<!-- βœ“ GOOD -->
<button onclick={foo} />
<button
  onclick={() => {
    /*  */
  }}
/>

<!-- βœ— BAD -->
<button onclick={
Unexpected object in event handler. (svelte/no-not-function-handler)
{ foo }
} />
<button onclick={
Unexpected number value in event handler. (svelte/no-not-function-handler)
bar
} />

# πŸ”§ Options

Nothing.

# πŸš€ Version

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

# πŸ” Implementation