PowerShell / PSScriptAnalyzer

Download ScriptAnalyzer from PowerShellGallery
https://www.powershellgallery.com/packages/PSScriptAnalyzer/
MIT License
1.8k stars 366 forks source link

PSAlignAssignmentStatement: Ignore hashtables with a single key-value pair #1983

Closed liamjpeters closed 3 months ago

liamjpeters commented 3 months ago

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

bergmeister commented 2 months ago

@liamjpeters what was the issue or reason for closing this PR? Happy to support/help where needed

liamjpeters commented 2 months ago

@bergmeister - I'm not the most familiar with git. I used the main branch of my fork for this PR but wanted to use a different branch. Didn't know how to do that so got things organised locally, closed this PR and opened a new one. #1986

Hopefully I've not created any issues by doing so

bergmeister commented 2 months ago

Gotcha, no worries