Skip to content
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

Add possibility to silence module-script-reactive-declaration warning #5954

Closed
dummdidumm opened this issue Feb 3, 2021 · 7 comments · Fixed by #6504
Closed

Add possibility to silence module-script-reactive-declaration warning #5954

dummdidumm opened this issue Feb 3, 2021 · 7 comments · Fixed by #6504

Comments

@dummdidumm
Copy link
Member

dummdidumm commented Feb 3, 2021

Is your feature request related to a problem? Please describe.
In #5847 I expressed the concern that people might want to use module variables inside reactive statements, knowing that reactivity will not be triggered on changes to them. This means it should be possible to silence the warning.

Describe the solution you'd like
<!-- svelte-ignore module-script-reactive-declaration --> at the top of the component or // svelte-ignore module-script-reactive-declaration should silence the warning

How important is this feature to you?
Nice to have to not have this warning make unnecessary noise

Workaround in the meantime
You can globally silence this. For svelte-check, do --compiler-warnings "module-script-reactive-declaration:ignore". A similar option is available for the VS Code extension.

@ribizli
Copy link

ribizli commented Feb 21, 2021

IMHO, just don't warn on const would be really helpful.

@lights0123
Copy link

And functions too

@natemartinsf
Copy link

Agree. I'm exporting a const to use the value in other modules, and that's causing this warning too. I suppose workarounds are to make this a readable store (which seems a lot heavier than just exporting a const), or creating a constants.js file that gets imported in multiple places.

@j3rem1e
Copy link

j3rem1e commented Apr 1, 2021

I don't see the point of this warning. A warning should be emitted if the code can be improved or if something is wrong.
Here, there is nothing to do but stop using scripts module.

This warning sounds like "read the doc".

@stale
Copy link

stale bot commented Jun 30, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Jun 30, 2021
@dummdidumm
Copy link
Member Author

Still relevant

@stale stale bot removed the stale-bot label Jul 1, 2021
dummdidumm pushed a commit to dummdidumm/svelte that referenced this issue Jul 7, 2021
including css-unused-selector, unused-export-let, module-script-reactive-declaration
Fixes sveltejs#5954
Related to sveltejs#5281
dummdidumm added a commit that referenced this issue Jul 14, 2021
including css-unused-selector, unused-export-let, module-script-reactive-declaration
Fixes #5954
Related to #5281
dummdidumm pushed a commit that referenced this issue Jul 14, 2021
…n reactive statements (#6510)

The warning was too strict, since there are valid use cases for having non-reactive variables inside reactive statements
Fixes #5954
@Conduitry
Copy link
Member

This has been released in 3.39.0.

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

Successfully merging a pull request may close this issue.

6 participants