Skip to content

variable assignments are not aligned #2127

@xhzkp

Description

@xhzkp

After executing the following code, the = in variable assignments are not aligned, and the = in the first hashtable are also not aligned. I tested this in PowerShell 5.1 on Windows 10.

cls
$s = @'
$hashtable = @{ property1    ="value"
    anotherProperty= "another value"
}
$hashtable = @{
    property1 = "value"
    anotherProperty = "another value"
}
$hashtable = @{
    property1              = "value"
    anotherProperty = "another value"
}
$a= "hello"
   $ccc = "world"
 $b="Hi"
function foo {
"hello"
}
'@
$settings = @{
    IncludeRules = @("PSPlaceOpenBrace", "PSUseConsistentIndentation", "PSUseConsistentWhitespace","PSAlignAssignmentStatement")
    Rules = @{
        PSPlaceOpenBrace = @{
            Enable = $true
            OnSameLine = $false
        }
        PSUseConsistentIndentation = @{
        Enable = $true
			Kind = 'tab' # space,tab
			IndentationSize = 1
			PipelineIndentation = 'NoIndentation'
        }
        PSAlignAssignmentStatement = @{
            Enable = $true
            CheckHashtable = $true
        }
    }
}
Invoke-Formatter -ScriptDefinition $s -Settings $settings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions