From 433a542ef70f17f68806ae7581dd9992d7c9622d Mon Sep 17 00:00:00 2001 From: NWarila <33955773+NWarila@users.noreply.github.com> Date: Sun, 14 Jun 2026 00:07:32 +0000 Subject: [PATCH] Tighten whitespace analyzer settings --- PSScriptAnalyzerSettings.psd1 | 16 ++++++++++------ docs/STYLE-GUIDE.md | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 index 6247e7d..bfa96db 100644 --- a/PSScriptAnalyzerSettings.psd1 +++ b/PSScriptAnalyzerSettings.psd1 @@ -43,16 +43,20 @@ } PSUseConsistentWhitespace = @{ - Enable = $true - CheckInnerBrace = $true - CheckOpenBrace = $true - CheckOpenParen = $true - CheckOperator = $false - CheckSeparator = $true + Enable = $true + CheckInnerBrace = $true + CheckOpenBrace = $true + CheckOpenParen = $true + CheckOperator = $true + CheckParameter = $true + CheckPipe = $true + CheckSeparator = $true + IgnoreAssignmentOperatorInsideHashTable = $true } PSAlignAssignmentStatement = @{ Enable = $true + CheckEnums = $false CheckHashtable = $true } diff --git a/docs/STYLE-GUIDE.md b/docs/STYLE-GUIDE.md index 4b98408..ffc29fb 100644 --- a/docs/STYLE-GUIDE.md +++ b/docs/STYLE-GUIDE.md @@ -250,12 +250,27 @@ $false` is the lever (its `GetViolationsForUncuddledBranches` path flags uncuddl PSPlaceOpenBrace = @{ Enable = $true; OnSameLine = $true; NewLineAfter = $true; IgnoreOneLineBlock = $true } PSPlaceCloseBrace = @{ Enable = $true; NewLineAfter = $false; IgnoreOneLineBlock = $true; NoEmptyLineBefore = $false } PSUseConsistentIndentation = @{ Enable = $true; Kind = 'space'; IndentationSize = 2 } +PSUseConsistentWhitespace = @{ + Enable = $true + CheckInnerBrace = $true + CheckOpenBrace = $true + CheckOpenParen = $true + CheckOperator = $true + CheckParameter = $true + CheckPipe = $true + CheckSeparator = $true + IgnoreAssignmentOperatorInsideHashTable = $true +} +PSAlignAssignmentStatement = @{ Enable = $true; CheckEnums = $false; CheckHashtable = $true } ``` `Invoke-Formatter` can drive a bulk reformat from the same settings, but it has known edge bugs around branch placement (half-cuddled `else`, no inter-statement newline insertion — issues #508, #794), so any auto-reformat must be re-linted and the -`else`/`catch`/`finally` sites eyeballed. +`else`/`catch`/`finally` sites eyeballed. Operator, pipe, and parameter spacing are +also formatter-enforced; the hashtable assignment carve-out is deliberate so aligned +hashtables continue to satisfy `PSAlignAssignmentStatement`. Enum member alignment is +disabled because `CheckOperator` owns assignment-operator spacing outside hashtables. ---