# svelte/no-reactive-functions

it’s not necessary to define functions in reactive statements

  • πŸ’‘ Some problems reported by this rule are manually fixable by editor suggestions.

# πŸ“– Rule Details

This rule reports whenever a function is defined in a reactive statement. This isn’t necessary, as each time the function is executed it’ll already have access to the latest values necessary. Redefining the function in the reactive statement is just a waste of CPU cycles.

<script>
  /* eslint svelte/no-reactive-functions: "error" */

  /* βœ“ GOOD */
  const arrowFn = () => {
    /* ... */
  };
  const func = function () {
    /* ... */
  };

  /* βœ— BAD */
  $: arrowFn = () => {
    /* ... */
  };
  $: func = function () {
    /* ... */
  };
</script>

# πŸ”§ Options

Nothing

# ❀️ Compatibility

This rule was taken from @tivac/eslint-plugin-svelte.
This rule is compatible with @tivac/svelte/reactive-functions rule.

# πŸš€ Version

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

# πŸ” Implementation