Skip to content

Have PowerShell formatter remove trailing whitespace when formatting a file #5111

Open
@plmcgrn

Description

@plmcgrn

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.

Summary

When allowing the PSScriptAnalyzerSettings.psd1 to show Information-level problems, it adds a lot of overhead in formatting files that have lines with trailing whitespaces. Since this recommendation is mostly aesthetic/non-breaking, as is the automated code formatting in general, I'd like to see the formatter for PowerShell remove these trailing whitespaces characters.

https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/rules/avoidtrailingwhitespace?view=ps-modules

Because we can't store a centralized configuration for PSScriptAnalyzerSettings.psd1 in source control at the repo/workspace level to have it be taken automatically be any user working on that repo, having per-user rules to suppress this aren't really practical. I did see a separate thread in this project's issues noting individual users can set a configuration flag to do this, but again, having every user do that themselves vs. having a central linting rule is frustrating to maintain adherence on. Short of having a CI/CD pipeline hard reject any PSScriptAnalyzer errors to force them to check in cleaned code, an automated approach is best.

image

Proposed Design

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions