PSAvoidTrailingWhitespace: Rule not applied when using formatter + single character lines with trailing whitespace are truncated#1993
Conversation
…dered by the formatter
…character, followed by multiple white-spaces were truncated when fixed/formatted
…ormatter with PSAvoidTrailingWhitespace and also checking that single-character lines that have trailing whitespace are not removed
Ju-l1a
left a comment
There was a problem hiding this comment.
It works as expected now and all tests pass. Looks good to me!
|
I don't know if this is to do with this issue specifically but I've found that with this branch the fix for Edit: actually I'm getting the same for |
|
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 $ScriptDefBut is fixed when running: Invoke-Formatter -ScriptDefinition $ScriptDef -Settings $SettingsHope that helps! |
andyleejordan
left a comment
There was a problem hiding this comment.
Thanks! Sorry it took so long to get to these.


PR Summary
Added
PSAvoidTrailingWhitespaceto the list of rules considered by the formatter (an entry for the rule is still required in theRulespart ofsettings).Fixes The PSAvoidTrailingWhitespace rule is not applied when using Invoke-Formatter #1992
Fixed an issue where lines starting with and containing a single character, that have trailing white-space, are truncated when formatted/fixed. See comment in #1992 for explanation.
Fixes Fixing PSAvoidTrailingWhitespace is broken #1757
PR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.