Skip to content

Commit 061effe

Browse files
bergmeisterrjmholt
authored andcommitted
Add AutoCorrectAliases setting (PR to be made in VS-Code repo as well) to add support for optionally correcting aliases as well (added in PSSA 1.18.2) (#1021)
1 parent 974bb1d commit 061effe

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/PowerShellEditorServices.Protocol/Server/LanguageServerSettings.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ public CodeFormattingSettings(CodeFormattingSettings codeFormattingSettings)
190190
}
191191
}
192192

193+
public bool AutoCorrectAliases { get; set; }
193194
public CodeFormattingPreset Preset { get; set; }
194195
public bool OpenBraceOnSameLine { get; set; }
195196
public bool NewLineAfterOpenBrace { get; set; }
@@ -249,16 +250,7 @@ public Hashtable GetPSSASettingsHashtable(
249250

250251
private Hashtable GetCustomPSSASettingsHashtable(int tabSize, bool insertSpaces)
251252
{
252-
return new Hashtable
253-
{
254-
{"IncludeRules", new string[] {
255-
"PSPlaceCloseBrace",
256-
"PSPlaceOpenBrace",
257-
"PSUseConsistentWhitespace",
258-
"PSUseConsistentIndentation",
259-
"PSAlignAssignmentStatement"
260-
}},
261-
{"Rules", new Hashtable {
253+
var ruleConfigurations = new Hashtable {
262254
{"PSPlaceOpenBrace", new Hashtable {
263255
{"Enable", true},
264256
{"OnSameLine", OpenBraceOnSameLine},
@@ -292,7 +284,25 @@ private Hashtable GetCustomPSSASettingsHashtable(int tabSize, bool insertSpaces)
292284
{"PSUseCorrectCasing", new Hashtable {
293285
{"Enable", UseCorrectCasing}
294286
}},
295-
}}
287+
};
288+
if (AutoCorrectAliases)
289+
{
290+
ruleConfigurations.Add("PSAvoidUsingCmdletAliases", new Hashtable());
291+
}
292+
293+
return new Hashtable
294+
{
295+
{"IncludeRules", new string[] {
296+
"PSPlaceCloseBrace",
297+
"PSPlaceOpenBrace",
298+
"PSUseConsistentWhitespace",
299+
"PSUseConsistentIndentation",
300+
"PSAlignAssignmentStatement",
301+
"PSAvoidUsingCmdletAliases",
302+
}},
303+
{
304+
"Rules", ruleConfigurations
305+
},
296306
};
297307
}
298308
}

0 commit comments

Comments
 (0)