Skip to content

Latest commit

 

History

History
65 lines (45 loc) · 1.43 KB

no-not-function-handler.md

File metadata and controls

65 lines (45 loc) · 1.43 KB
pageClass sidebarDepth title description since
rule-details
0
svelte/no-not-function-handler
disallow use of not function in event handler
v0.5.0

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

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

🔧 Options

Nothing.

👫 Related Rules

🚀 Version

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

🔍 Implementation