-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Disable warnings through comments. #1861
Conversation
da4b9c0
to
47de5b9
Compare
47de5b9
to
b91f650
Compare
Good idea, especially if we continue to add more "linting" rules in future. Since the warning comes from svelte perhaps it should be something like If we go ahead with this, I'd like to also see Similar tools:
|
You're right, I like
|
I like having svlete in the comment name but I'm not sure about simply |
I quite like Maybe anything more fancy than what you've created here could be done as future iterations. Or even keep as is, the simplicity of this feels right in line with svelte's simplicity :) |
For me main problem only with autofocus... I want to disable only this one warning. |
Is there any other way to disable the autofocus warning? I have a login form, removing autofocus to satisfy Svelte harms usability for most users. |
You can remove specific warnings by giving a custom |
Thanks @Conduitry that worked like a charm! |
Thanks for the PR @RedHatter. I think it's important to be able to specify which warnings are being disabled, and I'm nervous about the use of the code frame for this sort of thing (feels brittle), so I've opened a new PR, #3351. Will close this in favour of that |
Allows disabling warnings using comments. In this example
The svelte compiler would warn
A11y: <a> element should have child content
but notA11y: <a> element should have an href attribute
.The comments can be place anywhere on the line the error occurred or by themselves on the previous line. For a comment to be valid it must start with
warn-disable
followed by the error code to ignore. White-space is ignored. After the error code comments can contain any text (like a normal comment) to allow the developer to describe why the warning is being ignored.The test whether of not to ignore a warning is done before custom
onwarn
ordefault_onwarn
is called. This is to ensure cases like the rollup plugin don't override this functionality.The name
I'm not sure
warn-disable
is the best name. Some alternativesleaving a11y out of the name might be a good idea to in case we ever add other types of warnings that might want to be ignored (unless we already do? I didn't see anything else).
ignore-warning
is more expressive of the purpose butwarn-disable
is closer to whateslint
uses.