Skip to content

Allow the user to ignore warnings in the script tag #11822

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
paoloricciuti opened this issue May 29, 2024 · 10 comments · Fixed by #11833
Closed

Allow the user to ignore warnings in the script tag #11822

paoloricciuti opened this issue May 29, 2024 · 10 comments · Fixed by #11833
Labels
Milestone

Comments

@paoloricciuti
Copy link
Member

Describe the bug

As per #11818 (comment) currently there's no way to silence a warning in the script tag.

The user should be able to use the same svelte-ignore comments as in the template

Reproduction

REPL

Logs

No response

System Info

repl

Severity

annoyance

@Conduitry
Copy link
Member

Hm. I'm not sure how we'd want something like this to interact with, for example, ignore comments in ESLint, where I think we're also surfacing these warnings. Presumably a comment like the one proposed in this issue would prevent the compiler from emitting the warning, which would prevent ESLint from knowing about it and reporting it. Would it be confusing to have two ways of doing the same thing?

@dummdidumm
Copy link
Member

// svelte-ignore works in Svelte 4, so this is a regression in Svelte 5 that needs fixing.

@dummdidumm dummdidumm added this to the 5.0 milestone May 29, 2024
@dummdidumm dummdidumm added the bug label May 29, 2024
@Conduitry
Copy link
Member

Oh, I didn't realize this existed in Svelte 4 already. I guess I'm not going to worry then about the two different ways of ignoring warnings.

@paoloricciuti
Copy link
Member Author

Uh actually: some warning can actually be silenced in the script...there are two or three that can't because they are raised after the analysis walked the whole ast based on the bindings.

@dummdidumm
Copy link
Member

Oh right, yeah some are not silenceable right now. Not sure if worth to find workarounds for all of them

@paoloricciuti
Copy link
Member Author

Oh right, yeah some are not silenceable right now. Not sure if worth to find workarounds for all of them

Yeah i was kinda trying to find a solution but it's very difficult because the check needs to happen after the walk but after the ignore_stack is only filled during the walk.

I tried to move the ignore_pop and ignore_stack management in the scope but sometimes the code to ignore is not a binding and it's a function call. I wonder if is worth trying to change the logic for the ignore_stack and instead of pushing into an array it literally does the check looping over parent.children inside the warning function itself.

I'll try again later

@paoloricciuti
Copy link
Member Author

What if we attach the "ignore information" to node itself? Then the warning function can just check the ignore from the node itself.

I remember the will to remove metadata from the nodes tho right?

@dummdidumm
Copy link
Member

It was on the node itself for some time but that had drawbacks, too, in some locations. I think the most practical solution is to keep the current system and add one-off hacks/fixes to those specific warnings - and probably also not all of them. I don't think you want to silence them all (i.e. it makes no sense to ignore some of these anyway)

@paoloricciuti
Copy link
Member Author

It was on the node itself for some time but that had drawbacks, too, in some locations. I think the most practical solution is to keep the current system and add one-off hacks/fixes to those specific warnings - and probably also not all of them. I don't think you want to silence them all (i.e. it makes no sense to ignore some of these anyway)

I took a shot with an idea that i had...let me know how bad it is 😄

@nickolasgregory
Copy link

Sorry to comment on a closed issue.
Is there any chance this could be made to work in the docblock with my comments, @type etc.. ala;

	/**
	 * Not state related
	 * @type {object}
	 * @svelte-ignore non_reactive_update
	 */
	let a = {}

Rather than appending a separate line for // svelte-ignore non_reactive_update

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

Successfully merging a pull request may close this issue.

4 participants