microsoft/hve-core
Publicmirrored from https://github.com/microsoft/hve-coreAvailable
scripts/linting/PSScriptAnalyzer.psd1
69lines · modeblame
d19c9b3alittleKitchen4 months ago | 1 | # Copyright (c) Microsoft Corporation. |
| 2 | # SPDX-License-Identifier: MIT | |
| 3 | | |
9f975225Bill Berry7 months ago | 4 | # PSScriptAnalyzer Settings for HVE Core |
| 5 | # Purpose: Enforce PowerShell best practices and coding standards | |
| 6 | | |
| 7 | @{ | |
| 8 | # Severity levels: Error, Warning, Information | |
| 9 | # Only include rules that should fail the build | |
| 10 | Severity = @('Error', 'Warning') | |
| 11 | | |
| 12 | # Include all default rules | |
| 13 | IncludeDefaultRules = $true | |
| 14 | | |
| 15 | # Exclude specific rules that may not apply | |
| 16 | ExcludeRules = @( | |
| 17 | # Allow Write-Host for user-facing scripts (console output is intentional) | |
| 18 | 'PSAvoidUsingWriteHost', | |
| 19 | # Allow plural nouns for functions that semantically return multiple items (e.g., Get-GitIgnorePatterns) | |
| 20 | 'PSUseSingularNouns', | |
| 21 | # Skip ShouldProcess for simple GitHub Actions helper functions that only append to files | |
| 22 | 'PSUseShouldProcessForStateChangingFunctions', | |
| 23 | # Skip false positive for error redirection operator (2>$null) | |
| 24 | 'PSPossibleIncorrectUsageOfRedirectionOperator' | |
| 25 | ) | |
| 26 | | |
| 27 | # Custom rule configurations | |
| 28 | Rules = @{ | |
| 29 | # Enforce cmdlet alias avoidance (use full cmdlet names) | |
| 30 | PSAvoidUsingCmdletAliases = @{ | |
| 31 | Enable = $true | |
| 32 | } | |
| 33 | | |
| 34 | # Require explicit parameter types | |
| 35 | PSUseCompatibleSyntax = @{ | |
| 36 | Enable = $true | |
| 37 | TargetVersions = @('5.1', '7.0', '7.2') | |
| 38 | } | |
| 39 | | |
| 40 | # Enforce proper comment-based help | |
| 41 | PSProvideCommentHelp = @{ | |
| 42 | Enable = $true | |
| 43 | ExportedOnly = $false | |
| 44 | BlockComment = $true | |
| 45 | VSCodeSnippetCorrection = $true | |
| 46 | Placement = 'before' | |
| 47 | } | |
| 48 | | |
| 49 | # Enforce proper OutputType declarations | |
| 50 | PSUseOutputTypeCorrectly = @{ | |
| 51 | Enable = $true | |
| 52 | } | |
| 53 | | |
| 54 | # Enforce proper verb usage | |
| 55 | PSUseApprovedVerbs = @{ | |
| 56 | Enable = $true | |
| 57 | } | |
| 58 | | |
| 59 | # Require BOM for UTF-8 encoded files | |
| 60 | PSUseBOMForUnicodeEncodedFile = @{ | |
| 61 | Enable = $true | |
| 62 | } | |
| 63 | | |
| 64 | # Avoid using positional parameters | |
| 65 | PSAvoidUsingPositionalParameters = @{ | |
| 66 | Enable = $false # Disabled - common in scripts | |
| 67 | } | |
| 68 | } | |
| 69 | } |