Hide VSCode warning for PSUseApprovedVerbs
#VSCode #PowerShell #Windows #MacOS
I use VSCode for all my coding. One thing I appreciate about the PowerShell module in VSCode is how it recommends best practices inline with my script.
One of the recommended best practices for PowerShell is to use a list of approved verbs that define which words can be used in functions. This makes sense—I love the way PowerShell uses the Verb-Noun
structure to keep things standardized and avoid confusion.
Sometimes the recommended list of verbs doesn't include what I'm trying to do, like “Check” or “Verify”. When I write a function using an unapproved verb, VSCode puts an orange squiggly line and these alerts get counted with others that I would consider more important:
This makes my VSCode environment noisy and it can be difficult to sift through all the alerts to try to identify real issues. After some digging, I found a way to hide these alerts without turning off the whole PSScriptAnalyzer
feature.
Note: In the code examples, I've removed the signature blocks. Don't change or delete this section in your environment—If you do, you'll need to re-install the PowerShell extension and/or VSCode.