PSAvoidTrailingWhitespace: Rule not applied when using formatter + single character lines with trailing whitespace are truncated by liamjpeters · Pull Request #1993 · PowerShell/PSScriptAnalyzer
Hey @Ju-l1a 👋,
You need to tell the formatter to include that rule when carrying out the formatting.
$Settings = @{ IncludeRules = @("PSAvoidTrailingWhitespace") Rules = @{ "PSAvoidTrailingWhitespace" = @{} } }
So the below code, with lots of trailing whitespace:
$ScriptDef = @" Function Get-Example { 'Example'`t`t`t }`t`t`t "@
Is not altered when running:
Invoke-Formatter -ScriptDefinition $ScriptDef
But is fixed when running:
Invoke-Formatter -ScriptDefinition $ScriptDef -Settings $Settings
Hope that helps!

