Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.7 KB

no-reactive-functions.md

File metadata and controls

52 lines (35 loc) · 1.7 KB
pageClass sidebarDepth title description
rule-details
0
svelte/no-reactive-functions
It's not necessary to define functions in reactive statements

svelte/no-reactive-functions

It's not necessary to define functions in reactive statements

  • This rule has not been released yet.
  • 💡 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.

🔍 Implementation