◐ Shell
clean mode source ↗

PSAlignAssignmentStatement: Ignore hashtables with a single key-value pair by liamjpeters · Pull Request #1986 · PowerShell/PSScriptAnalyzer

PR Summary

Hashtables with a single key-value pair should be ignored by PSAlignAssignmentStatement as there is nothing to align.

There are other rules that handle whitespace around operators etc which can handle formatting according to the users preference.

Currently:

Invoke-Formatter -ScriptDefinition "@{'Key'='Value'}" -Settings @{
    Rules = @{
        PSAlignAssignmentStatement = @{
            Enable = $true
            CheckHashtable = $true
        }
    }
}

Results in:

Note the space added after the hashtable key

Resolves #1979

PR Checklist