|
| 1 | +# PSScriptAnalyzer settings — the enforcement mechanism for the PowerShell coding |
| 2 | +# standard (src/docs/Coding-Standards/PowerShell/index.md). The standard is the |
| 3 | +# source of truth; every rule configured here is derived from it. Change a rule by |
| 4 | +# changing the standard first, then reflect it here — never the other way around. |
| 5 | +# |
| 6 | +# super-linter discovers this file automatically as POWERSHELL_CONFIG_FILE |
| 7 | +# (.powershell-psscriptanalyzer.psd1) under .github/linters. |
| 8 | +@{ |
| 9 | + # Run the full default rule set — approved verbs, singular nouns, alias bans, |
| 10 | + # $null-on-the-left comparisons, Invoke-Expression, unused variables, and the |
| 11 | + # rest — then tighten the formatting rules below to match the standard. |
| 12 | + IncludeDefaultRules = $true |
| 13 | + |
| 14 | + # Gate on errors and warnings; both map to rules the standard requires. |
| 15 | + Severity = @('Error', 'Warning') |
| 16 | + |
| 17 | + Rules = @{ |
| 18 | + # One True Brace Style: opening brace on the statement line, closing brace |
| 19 | + # on its own line with no blank line before it. NewLineAfter stays false on |
| 20 | + # the close brace so else / elseif / catch / finally sit on the same line as |
| 21 | + # the preceding brace ("} else {"), as the standard requires. |
| 22 | + PSPlaceOpenBrace = @{ |
| 23 | + Enable = $true |
| 24 | + OnSameLine = $true |
| 25 | + NewLineAfter = $true |
| 26 | + IgnoreOneLineBlock = $true |
| 27 | + } |
| 28 | + PSPlaceCloseBrace = @{ |
| 29 | + Enable = $true |
| 30 | + NewLineAfter = $false |
| 31 | + IgnoreOneLineBlock = $true |
| 32 | + NoEmptyLineBefore = $true |
| 33 | + } |
| 34 | + |
| 35 | + # Indent with four spaces, never tabs. |
| 36 | + PSUseConsistentIndentation = @{ |
| 37 | + Enable = $true |
| 38 | + Kind = 'space' |
| 39 | + IndentationSize = 4 |
| 40 | + PipelineIndentation = 'IncreaseIndentationForFirstPipeline' |
| 41 | + } |
| 42 | + |
| 43 | + # One space around operators and after commas, and consistent brace and |
| 44 | + # parenthesis spacing. |
| 45 | + PSUseConsistentWhitespace = @{ |
| 46 | + Enable = $true |
| 47 | + CheckInnerBrace = $true |
| 48 | + CheckOpenBrace = $true |
| 49 | + CheckOpenParen = $true |
| 50 | + CheckOperator = $true |
| 51 | + CheckPipe = $true |
| 52 | + CheckSeparator = $true |
| 53 | + } |
| 54 | + } |
| 55 | +} |
0 commit comments