@@ -168,6 +168,7 @@ public CodeFormattingSettings(CodeFormattingSettings codeFormattingSettings)
168
168
}
169
169
}
170
170
171
+ public bool AutoCorrectAliases { get ; set ; }
171
172
public CodeFormattingPreset Preset { get ; set ; }
172
173
public bool OpenBraceOnSameLine { get ; set ; }
173
174
public bool NewLineAfterOpenBrace { get ; set ; }
@@ -223,44 +224,57 @@ public Hashtable GetPSSASettingsHashtable(
223
224
224
225
private Hashtable GetCustomPSSASettingsHashtable ( int tabSize , bool insertSpaces )
225
226
{
227
+ var ruleConfigurations = new Hashtable {
228
+ { "PSPlaceOpenBrace" , new Hashtable {
229
+ { "Enable" , true } ,
230
+ { "OnSameLine" , OpenBraceOnSameLine } ,
231
+ { "NewLineAfter" , NewLineAfterOpenBrace } ,
232
+ { "IgnoreOneLineBlock" , IgnoreOneLineBlock }
233
+ } } ,
234
+ { "PSPlaceCloseBrace" , new Hashtable {
235
+ { "Enable" , true } ,
236
+ { "NewLineAfter" , NewLineAfterCloseBrace } ,
237
+ { "IgnoreOneLineBlock" , IgnoreOneLineBlock }
238
+ } } ,
239
+ { "PSUseConsistentIndentation" , new Hashtable {
240
+ { "Enable" , true } ,
241
+ { "IndentationSize" , tabSize } ,
242
+ { "Kind" , insertSpaces ? "space" : "tab" }
243
+ } } ,
244
+ { "PSUseConsistentWhitespace" , new Hashtable {
245
+ { "Enable" , true } ,
246
+ { "CheckOpenBrace" , WhitespaceBeforeOpenBrace } ,
247
+ { "CheckOpenParen" , WhitespaceBeforeOpenParen } ,
248
+ { "CheckOperator" , WhitespaceAroundOperator } ,
249
+ { "CheckSeparator" , WhitespaceAfterSeparator }
250
+ } } ,
251
+ { "PSAlignAssignmentStatement" , new Hashtable {
252
+ { "Enable" , true } ,
253
+ { "CheckHashtable" , AlignPropertyValuePairs }
254
+ } } ,
255
+ { "PSUseCorrectCasing" , new Hashtable {
256
+ { "Enable" , UseCorrectCasing }
257
+ } } ,
258
+ } ;
259
+
260
+ if ( AutoCorrectAliases )
261
+ {
262
+ ruleConfigurations . Add ( "PSAvoidUsingCmdletAliases" , new Hashtable ( ) ) ;
263
+ }
264
+
226
265
return new Hashtable
227
266
{
228
267
{ "IncludeRules" , new string [ ] {
229
268
"PSPlaceCloseBrace" ,
230
269
"PSPlaceOpenBrace" ,
231
270
"PSUseConsistentWhitespace" ,
232
271
"PSUseConsistentIndentation" ,
233
- "PSAlignAssignmentStatement"
272
+ "PSAlignAssignmentStatement" ,
273
+ "PSAvoidUsingCmdletAliases" ,
234
274
} } ,
235
- { "Rules" , new Hashtable {
236
- { "PSPlaceOpenBrace" , new Hashtable {
237
- { "Enable" , true } ,
238
- { "OnSameLine" , OpenBraceOnSameLine } ,
239
- { "NewLineAfter" , NewLineAfterOpenBrace } ,
240
- { "IgnoreOneLineBlock" , IgnoreOneLineBlock }
241
- } } ,
242
- { "PSPlaceCloseBrace" , new Hashtable {
243
- { "Enable" , true } ,
244
- { "NewLineAfter" , NewLineAfterCloseBrace } ,
245
- { "IgnoreOneLineBlock" , IgnoreOneLineBlock }
246
- } } ,
247
- { "PSUseConsistentIndentation" , new Hashtable {
248
- { "Enable" , true } ,
249
- { "IndentationSize" , tabSize } ,
250
- { "Kind" , insertSpaces ? "space" : "tab" }
251
- } } ,
252
- { "PSUseConsistentWhitespace" , new Hashtable {
253
- { "Enable" , true } ,
254
- { "CheckOpenBrace" , WhitespaceBeforeOpenBrace } ,
255
- { "CheckOpenParen" , WhitespaceBeforeOpenParen } ,
256
- { "CheckOperator" , WhitespaceAroundOperator } ,
257
- { "CheckSeparator" , WhitespaceAfterSeparator }
258
- } } ,
259
- { "PSAlignAssignmentStatement" , new Hashtable {
260
- { "Enable" , true } ,
261
- { "CheckHashtable" , AlignPropertyValuePairs }
262
- } } ,
263
- } }
275
+ {
276
+ "Rules" , ruleConfigurations
277
+ } ,
264
278
} ;
265
279
}
266
280
}
0 commit comments