Add Support for Suppressing Warnings/Errors per Line in Config Validation
j
jdalittle@gmail.com
I'm using the VS Code extension, but I presume it's the language server (?) that would be responsible for this. I want to be able to add some kind of ignore next line/current line to suppress warnings and (possibly) errors, so it doesn't continue to report problems that I've address/am intentionally leaving.
j
jdalittle@gmail.com
Still sad this is not a thing. Very annoying to have tens of "error" lines in my file when it's not really an error.
Would also accept simple option to disable config validation while still using other features.
P
Parker Rowe
jdalittle@gmail.com Hey! We are taking a look at this now and exploring possible solutions.
Having the option to simply disable the language server's diagnostics via the VSCode extension is one option that is useful as a nuclear option to get rid of erroneous errors.
In terms of granular control over per-line diagnostics, I like the suggestion you had. It's quite similar to how TypeScript and ESLint allow for exceptions to their language server errors through ignore comments. The practice is well known and familiar for many developers.
e.g.
```yaml
cci-ignore-file # Suppress all diagnostics for entire file
jobs:
my-job: # cci-ignore (suppress on current line)
cci-ignore-next-line # Suppress on next line only
executor: unknown-executor
cci-ignore-start # Begin suppression block
parallelism: 1
unused_key: value
another_issue: here
cci-ignore-end # End suppression block
```
This solution would also mean that we can suggest these comments as code actions via the Language Server Protocol. That way when users try to view fixes for the errors, their editor (VSCode or any other editor that supports it like Neovim) would suggest inserting one of these comments as a valid "fix".
Would this approach suit your needs for ignoring erroneous errors? Open to suggestions and feedback on this idea!
j
jdalittle@gmail.com
Parker Rowe, spot on. That'd be great.
P
Parker Rowe
jdalittle@gmail.com:
We have released diagnostic suppression comments in v0.25.0 of the langauge server!
https://github.com/CircleCI-Public/circleci-yaml-language-server/releases/tag/0.25.0
If using VSCode, you may need to restart your IDE for it to pull in the latest version of the language server. Hope this helps!
j
jdalittle@gmail.com
Parker Rowe, I just tried it, and it is working. I had to put 53 ignores for the same error (cannot find context). Would be great to be able to ignore in file for a class of error. I see I can ignore _all_ errors in file, but would prefer to only ignore that error class.
Well, TBH, would like for that check to correctly work, because those contexts definitely exist. But anyways, just a thought on next level. It's great to have this lever now. Thanks!
P
Parker Rowe
jdalittle@gmail.com:
Great feedback! I was considering adding error classes but decided against it for now since we wanted to get this in people's hands first.
Agreed that the better solution here would be to just fix the underlying errors first rather than have people resort to ignoring errors.
Appreciate your patience in getting this out!
j
jdalittle@gmail.com
Parker Rowe, sounds good. I am glad you optimized for speed of delivery, so we OCD folks can calm down now. :)
Autopilot
Merged in a post:
Disable or Customize Language Server Validations in VS Code
j
jdalittle@gmail.com
Not infrequently, I get incorrect errors from the language server, or warnings I don't care about. It is distracting and annoying that there's no way to disable these as with most linters.
The easy button/option for me would be to at least allow disabling validations/not showing warnings/errors when viewing the file. I'd still like to keep autocomplete and other related features, but just let me opt out of the validations.
Even better would be "ignore next line" suppression and/or "ignore in file".
Even better would be to ignore classes/rules. Like, the context validation for me is totally wrong--it says contexts don't exist that do. And I really don't care to have that validated anyways.