PSScriptAnalyzer icon indicating copy to clipboard operation
PSScriptAnalyzer copied to clipboard

PSAlignAssignmentStatement: Ignore hashtables with a single key-value pair

Open liamjpeters opened this issue 1 year ago • 1 comments

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:

@{'Key' ='Value'}

Note the space added after the hashtable key

Resolves #1979

PR Checklist

liamjpeters avatar Mar 27 '24 09:03 liamjpeters

My git-foo is not strong so this is a re-raise of https://github.com/PowerShell/PSScriptAnalyzer/pull/1983 where the full test checks were completed and passed

liamjpeters avatar Mar 27 '24 09:03 liamjpeters