# 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 */
Do not create functions inside reactive statements unless absolutely necessary. (svelte/no-reactive-functions)$: arrowFn = () => {
/* ... */
};
Do not create functions inside reactive statements unless absolutely necessary. (svelte/no-reactive-functions)$: 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