-
-
Notifications
You must be signed in to change notification settings - Fork 48
svelte/require-store-reactive-access #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for suggesting the rule! I still don't know how to type check if it's a store or not, but I think we can get TypeScript type information from a node like this: const tools = getTypeScriptTools(context)
if (!tools) {
return {}
}
const { service, ts } = tools
const checker = service.program.getTypeChecker()
// ...
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
const type = checker.getTypeAtLocation(tsNode); The following code is a deprecated rule the other day, but it may be helpful. |
typescript-eslint's |
We should also check references from |
I'll try to work on implementing this rule. |
Hello, this rule triggers when using custom stores methods, which is a bit annoying. Would it be possible to add some rule option to prevent that ? |
Please open a new issue. |
Sorry. Plus, the behaviour i'm experiencing is a little bit weirder than i thought, i'll investigate more before posting an actual issue. |
Motivation
This is coming from sveltejs/svelte#7984.
Description
Disallow to render store itself. Need to use
$
prefix orget
function.This rule is fixable.
Examples
Additional comments
Svelte can define your own store. So we need to support it at some point. (But I think it's difficult. Is there any way to provide it to TypeScript users?)
https://svelte.dev/docs#component-format-script-4-prefix-stores-with-$-to-access-their-values-store-contract
The text was updated successfully, but these errors were encountered: