- Notifications
You must be signed in to change notification settings - Fork407
PSAvoidTrailingWhitespace: Rule not applied when using formatter + single character lines with trailing whitespace are truncated#1993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It works as expected now and all tests pass. Looks good to me!
Ju-l1a commentedJul 17, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 |
liamjpeters commentedJul 17, 2024
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! |
andyleejordan left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks! Sorry it took so long to get to these.
d6eb35e intoPowerShell:mainUh oh!
There was an error while loading.Please reload this page.


Uh oh!
There was an error while loading.Please reload this page.
PR Summary
Added
PSAvoidTrailingWhitespaceto the list of rules considered by the formatter (an entry for the rule is still required in theRulespart ofsettings).FixesThe 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. Seecomment in #1992 for explanation.
FixesFixing 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.