Skip to content

Warn when stores are used without $ prefix. #7984

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

Closed
TheCymaera opened this issue Oct 29, 2022 · 4 comments
Closed

Warn when stores are used without $ prefix. #7984

TheCymaera opened this issue Oct 29, 2022 · 4 comments

Comments

@TheCymaera
Copy link
Contributor

Describe the problem

Occasionally, I forget to prefix stores with the $ symbol and don't find out until runtime.
Screen Shot

Describe the proposed solution

Svelte should emit a warning when stores are used as values.

Alternatives considered

None.

Importance

nice to have

@brunnerh
Copy link
Member

The problem is that there various intended uses without $, especially for custom stores that may have additional methods or properties.

@TheCymaera
Copy link
Contributor Author

The problem is that there various intended uses without $, especially for custom stores that may have additional methods or properties.

I think the error should only apply to stores that are used as the final value in the HTML.

For other uses, regular type-checking should work fine.

@baseballyama
Copy link
Member

I think this is not Svelte compiler's task.
I created new rule proposal at ESLint plugin.

sveltejs/eslint-plugin-svelte#282

@baseballyama
Copy link
Member

baseballyama commented Nov 3, 2022

This rule is implemented at v2.12.0 of eslint-plugin-svelte!

https://ota-meshi.github.io/eslint-plugin-svelte/rules/require-store-reactive-access/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants