microsoft/hve-core

Public

mirrored fromhttps://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
docs/227-add-governance

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

scripts/linting/PSScriptAnalyzer.psd1

66lines · modecode

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