PSScriptAnalyzer
PSScriptAnalyzer copied to clipboard
PSAlignAssignmentStatement: Ignore hashtables with a single key-value pair
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
- [x] PR has a meaningful title
- Use the present tense and imperative mood when describing your changes
- [x] Summarized changes
- [x] Change is not breaking
- [x] Make sure all
.cs,.ps1and.psm1files have the correct copyright header - [x] Make sure you've added a new test if existing tests do not effectively test the code changed and/or updated documentation
- [x] This PR is ready to merge and is not Work in Progress.
- If the PR is work in progress, please add the prefix
WIP:to the beginning of the title and remove the prefix when the PR is ready.
- If the PR is work in progress, please add the prefix
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