PowerShell / PowerShell/vscode-powershell

Have PowerShell formatter remove trailing whitespace when formatting a file

Offen
#5,111 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Area-Code Formatting Area-Script Analysis Issue-Enhancement
Vorherrschende Sprache
TypeScript
Sterne
1.9k
Forks
548
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Das Issue nennt keine Quelldatei und keinen Test. Beginne damit, die Implementierung des PowerShell-Formatierers in dieser TypeScript-VS Code-Erweiterung zu finden, und reproduziere die Formatierung anhand einer Datei mit nachgestellten Leerzeichen. Erledigt ist die Aufgabe, wenn die formatierte Ausgabe nachgestellte Leerzeichen entfernt, ohne nicht relevante Inhalte zu ändern, und dies durch die relevanten Formatierungstests abgedeckt ist, sofern solche vorhanden sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
powershell, typescript, vscode
Bereich
developer-experience, tooling
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.