PowerShell / PowerShell/PSScriptAnalyzer

Code Formatting : Whitespacing one line hashtable

Aperta
#1,113 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area - Rules Issue - Bug
Lingua principale
C#
Stelle
2.2k
Fork
414
Merge medio
13h 1m
PR unite (30g)
2

Descrizione

Hello
I am looking for a improvment on the current formatting tools by adding a whitespace after open bracket and before closing non empty curly brackets like :

#Actual
$emptyHash = @{ }               # an empty Hash
$myHash = @{foo = "bar"}

#Expected
$emptyHash = @{}                # an empty Hash
$myHash = @{ foo = "bar" } #whitespace after `{ `and before ` }`

Additional information:

  • I use the PowerShell extension on VS Code to format automaticaly my code on save.

  • My settings.json file:

{
    "editor.formatOnSave": true,
    "powershell.codeFormatting.preset": "Custom",
    "powershell.codeFormatting.alignPropertyValuePairs": true,
    "powershell.codeFormatting.ignoreOneLineBlock": false,
    "powershell.codeFormatting.newLineAfterCloseBrace": true,
    "powershell.codeFormatting.newLineAfterOpenBrace": true,
    "powershell.codeFormatting.openBraceOnSameLine": false,
    "powershell.codeFormatting.whitespaceAfterSeparator": true,
    "powershell.codeFormatting.whitespaceAroundOperator": true,
    "powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
    "powershell.codeFormatting.whitespaceBeforeOpenParen": true,
    "powershell.scriptAnalysis.enable": true,
    "files.trimTrailingWhitespace": true,
}

This feature exist on other language :
https://github.com/Microsoft/TypeScript/issues/9613#issuecomment-268460847

Regards,

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

La issue non indica file o test. Inizia individuando la gestione della formattazione del codice PowerShell per le hashtables su una sola riga e riproduci gli esempi nella issue con le impostazioni personalizzate indicate. Il lavoro è completato quando le hashtables non vuote tra parentesi graffe ricevono spazi bianchi circostanti, mentre le hashtables vuote rimangono invariate, con copertura per entrambi i casi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp, powershell
Ambito
developer-experience, tooling
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.