You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When destructuring a function out of a function argument, for example like this:
// `resolve` is a function that is destructured out of the function argumentasyncfunctionhandle({ event, resolve }){// ...}
ESLint yells at me:
error Avoid referencing unbound methods which may cause unintentional scoping of `this`.
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead @typescript-eslint/unbound-method
Destructuing the function argument is very common, and is the way it's done in both the Docs and Tutorial for the handle hook.
I don't think resolve uses this, so I think the issue would be solved by declaring Handle like this (using arrow function):
Describe the bug
When destructuring a function out of a function argument, for example like this:
ESLint yells at me:
Destructuing the function argument is very common, and is the way it's done in both the Docs and Tutorial for the handle hook.
I don't think
resolve
usesthis
, so I think the issue would be solved by declaringHandle
like this (using arrow function):or this (annotating with
this: void
):instead of this:
Note: The same issue applies to some other functions. At least
parent
inLayoutLoad
andPageLoad
comes to mind.Reproduction
Set up SvelteKit with ESLint and
@typescript-eslint/recommended-type-checked
.Set up a handle hook:
Logs
No response
System Info
System: OS: Linux 5.15 Debian GNU/Linux 12 (bookworm) 12 (bookworm) CPU: (16) x64 Intel(R) Xeon(R) W-11955M CPU @ 2.60GHz Memory: 4.39 GB / 15.23 GB Container: Yes Shell: 5.2.15 - /bin/bash Binaries: Node: 20.17.0 - /usr/local/bin/node Yarn: 1.22.22 - /usr/local/bin/yarn npm: 10.8.2 - /usr/local/bin/npm npmPackages: svelte: ^4.2.19 => 4.2.19
The text was updated successfully, but these errors were encountered: