-
Notifications
You must be signed in to change notification settings - Fork 235
Allow customization of code formatting rules #552
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 customize the rules by adding a PSScriptAnalyzerSettings.psd1 file to your workspace e.g.:
Then in the workspace's
@kapilmb Also added a way to enable/disable rules via the VSCode UI with the command |
I don't think changing the PSScriptAnalyzer settings file will affect code formatting though, that gets run with a different configuration (Kapil can correct me if I'm wrong). It'd be nice if users could include their own formatting rules though, so we'll need to find a way to make that work. |
On a related note, if the "remove trailing whitespace" rule is common / popular enough, I could just submit a PR to add it to the defaults. Extensibility is still nice to have, though :) |
I think I would use such a rule and would be a good addition to the current set. |
Submitted. Once it's merged and a new version of script analyzer is released, will do another PR to update this repo with the new rule. |
BTW there is a VSCode setting folks should use with PowerShell files:
I use this and never run into this issue in VSCode. :-) |
Well holy crap, Keith. I completely missed that one! :) |
In this block of code: https://github.com/PowerShell/PowerShellEditorServices/blob/master/src/PowerShellEditorServices.Protocol/Server/LanguageServerSettings.cs#L209
The list of PSScriptAnalyzer rules used to perform the Formatting function is hard-coded. It would be nice to have a way of extending this list to include custom rules. For example, I have one that removes any trailing whitespace from lines, but it doesn't run if I use VSCode's "Format Document" or "Format Selection" actions.
The text was updated successfully, but these errors were encountered: