Skip to content

Files

Latest commit

 

History

History
43 lines (31 loc) · 998 Bytes

no-not-function-handler.md

File metadata and controls

43 lines (31 loc) · 998 Bytes

Pattern: Use of non-function in event handler

Issue: -

Description

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 on:click={foo} />
<button
  on:click={() => {
    /*  */
  }}
/>

<!-- ✗ BAD -->
<button on:click={{ foo }} />
<button on:click={bar} />

🔧 Options

Nothing.

🚀 Version

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

🔍 Implementation