Change the severity of all StyleCop rules using .editorconfig

282 views Asked by At

How can I change the severity of all StyleCop rules using .editorconfig?

Configuring individual rules works:

dotnet_diagnostic.SA1202.severity = error

However, I'm looking for a global change that affects every rule.

1

There are 1 answers

0
hawky On BEST ANSWER

If you want all rules for all analyzers to be set, use this:

dotnet_analyzer_diagnostic.severity = error

If you want just the Stylecop.Analyzers package rules to be set, use this:

dotnet_analyzer_diagnostic.category-StyleCop.CSharp.AlternativeRules.severity = error
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = error
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.LayoutRules.severity = error
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.MaintainabilityRules.severity = error
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.NamingRules.severity = error
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.OrderingRules.severity = error
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.ReadabilityRules.severity = error
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.SpacingRules.severity = error
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.SpecialRules.severity = error

Individual rules can then be individually overridden, like this:

dotnet_diagnostic.SA1400.severity = warning