FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

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

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

Merged
Andy Jordan (andyleejordan) merged 1 commit into
PowerShell:mainfrom
liamjpeters:#1979IgnoreHashtablesWithASingleKVP
Feb 19, 2025
Merged

PSAlignAssignmentStatement: Ignore hashtables with a single key-value pair#1986
Andy Jordan (andyleejordan) merged 1 commit into
PowerShell:mainfrom
liamjpeters:#1979IgnoreHashtablesWithASingleKVP

Conversation

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

My git-foo is not strong so this is a re-raise of #1983 where the full test checks were completed and passed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice to fix this undesired side effect in this case. the formatting rules have so many special oddities 😅

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks!

…g on a single line, and not checked for violations.
Andy Jordan (andyleejordan) force-pushed the #1979IgnoreHashtablesWithASingleKVP branch from 57cb24b to d831fba Compare February 19, 2025 18:28
Andy Jordan (andyleejordan) merged commit 20135fb into PowerShell:main Feb 19, 2025
Liam Peters (liamjpeters) deleted the #1979IgnoreHashtablesWithASingleKVP branch February 21, 2025 11:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adds whitespace around operators with whitespaceAroundOperator set to false in some cases

3 participants


Back | FazBrowse Home | New Git URL