I'm facing an issue in Visual Studio Code where my functions are getting syntax highlighted based on approved verbs, and I'd like to know how to turn that off. When I use an approved verb, my function names show in yellow, but they turn white when I use verbs that aren't in the approved list. It's quite annoying! I'm currently using the PowerShell extension by Microsoft.
3 Answers
You can fix this by modifying the PSScriptAnalyzerSettings.psd1 file to ignore the approved verbs rule. Check out the GitHub page for guidance on how to set that up. It should help you get rid of that annoying highlighting!
Another option is to use the SuppressMessageAttribute. You can add this attribute to your functions: `[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseApprovedVerbs", "", Justification="sue me")]`. This will stop the highlighting for that specific function.
Honestly, if it’s not a cmdlet you're creating for shell binding, I wouldn’t stress about using approved verbs. Just name your functions whatever you like in PascalCase. It’s way more flexible for everyday coding!
Exactly! Sometimes it just feels good to break the rules a bit.