-
Notifications
You must be signed in to change notification settings - Fork 291
Auto format #110
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can set up some style rules in the VSCode preferences, either at the user or workspace level, and set it to format on save or paste (or change?). This currently seems limited to things like brace placement, extra whitespace at the end of lines and a few others.
That should be a good place to start though.
…________________________________
From: John McCarthy <notifications@github.com>
Sent: Thursday, May 17, 2018 3:14:21 AM
To: PoshCode/PowerShellPracticeAndStyle
Cc: Subscribed
Subject: [PoshCode/PowerShellPracticeAndStyle] Auto format (#110)
Does something like gofmt for golang or terraform format for Terraform exist for PowerShell?
It would be awesome for VS code or PSScriptAnalyzer to auto enforce the standards and even to be able to auto format documents.
It can take a loooot of time to refactor/format code.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#110>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AQDqFlgLne8cdTVL69qoAjbK94epeamnks5tzNz9gaJpZM4UCTiZ>.
|
Agreed. So far that is the only option I've seen. But as you alluded to, it is limited. We wouldn't be able to enforce all the settings outlines in the repo. |
I believe the current thoughts is that PSScriptAnalyzer within VS Code flags the rule violations up but it's up to you to resolve them. Which I think is a nice compromise between enforcing it (which it could get wrong) and doing nothing. |
I'd rather it auto format my code to meet community standards. |
You can format code with PSScriptAnalyzer from the command line: 6> Invoke-Formatter -ScriptDefinition {
>> if(1-eq1){
>> "yay!" }
>> else
>> {
>> "suck"
>> }
>> }
if (1 -eq 1) {
"yay!"
}
else {
"suck"
} Note that operating on files is bit clunky:
@bergmeister do you have anything to add to this? |
Can you be more specific about what you describe as limited? Is it that you would like to customize/tweak one of the 3 built om style rules or are the style rule definitions in PSSA about braces, whitespace, etc. not sufficient? |
Maybe I am not aware of all the settings you are pointing out? user settings -> powershell.codeformatting.* I still don't think it is enforcing all the rules outlined in this repo. Basically like terraform format, gofmt, etc works. |
@midacts There is an open issue (that is up for grabs) in PSSA to do the formatting with the correct casing: PowerShell/PSScriptAnalyzer#767 |
I think this can be closed now that |
Does something like
gofmt
for golang orterraform format
for Terraform exist for PowerShell?It would be awesome for VS code or PSScriptAnalyzer to auto enforce the standards and even to be able to auto format documents.
It can take a loooot of time to refactor/format code.
The text was updated successfully, but these errors were encountered: