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
According to the docs, getContext needs to call during component initialization.
Svelte team tried to implement this in the compiler, but this is a bit difficult, so I thought that we will implement this as ESLint rule.
I have read the documentation. It seems that getContext isn't the only thing that has to be called during component initialization. So other functions such as setContext, hasContext should also be checked. Also, it seems necessary to warn when used inside $:, not just in templates.
Additionally, I think the rule name should be something like valid-context-access.
baseballyama
changed the title
New Rule: svelte/no-getContext-in-template
New Rule: svelte/valid-context-accessMay 1, 2023
Motivation
This is came from sveltejs/svelte#7864
Description
According to the docs,
getContext
needs to call during component initialization.Svelte team tried to implement this in the compiler, but this is a bit difficult, so I thought that we will implement this as ESLint rule.
https://svelte.dev/docs#run-time-svelte-getcontext
Examples
Additional comments
No response
The text was updated successfully, but these errors were encountered: