Skip to content

Commit e33a4df

Browse files
committed
Core/Config: [<Obsolete>] attribs & more comments
Added [<Obsolete>] attribs and more comments around the fragments of deprecated APIs and other legacy stuff that should be removed soon.
1 parent d0977e9 commit e33a4df

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/FSharpLint.Core/Application/Configuration.fs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ let constructTypePrefixingRuleWithConfig rule (ruleConfig: RuleConfig<TypePrefix
156156
else
157157
None
158158

159+
160+
// Deprecated grouped configs. TODO: remove in next major release
161+
162+
[<Literal>]
163+
let private ObsoleteMsg = "Please provide formatting rules at root level. This type will be removed in the near future."
164+
[<Literal>]
165+
let private ObsoleteWarnTreatAsError = false
166+
167+
// to be able to use our own types that we mark as Obsolete
168+
#nowarn "44"
169+
170+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
159171
type TupleFormattingConfig =
160172
{ tupleCommaSpacing:EnabledConfig option
161173
tupleIndentation:EnabledConfig option
@@ -169,6 +181,7 @@ with
169181
Option.bind (constructRuleIfEnabled TupleParentheses.rule) this.tupleParentheses
170182
|]
171183

184+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
172185
type PatternMatchFormattingConfig =
173186
{ patternMatchClausesOnNewLine:EnabledConfig option
174187
patternMatchOrClausesOnNewLine:EnabledConfig option
@@ -184,6 +197,7 @@ with
184197
Option.bind (constructRuleIfEnabled PatternMatchExpressionIndentation.rule) this.patternMatchExpressionIndentation
185198
|]
186199

200+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
187201
type FormattingConfig =
188202
{ typedItemSpacing:RuleConfig<TypedItemSpacing.Config> option
189203
typePrefixing:RuleConfig<TypePrefixing.Config> option
@@ -205,6 +219,7 @@ with
205219
this.patternMatchFormatting |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat
206220
|]
207221

222+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
208223
type RaiseWithTooManyArgsConfig =
209224
{ failwithBadUsage:EnabledConfig option
210225
raiseWithSingleArgument:EnabledConfig option
@@ -224,6 +239,7 @@ with
224239
this.failwithfWithArgumentsMatchingFormatString |> Option.bind (constructRuleIfEnabled FailwithfWithArgumentsMatchingFormatString.rule) |> Option.toArray
225240
|]
226241

242+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
227243
type SourceLengthConfig =
228244
{ maxLinesInLambdaFunction:RuleConfig<Helper.SourceLength.Config> option
229245
maxLinesInMatchLambdaFunction:RuleConfig<Helper.SourceLength.Config> option
@@ -255,6 +271,7 @@ with
255271
this.maxLinesInClass |> Option.bind (constructRuleWithConfig MaxLinesInClass.rule) |> Option.toArray
256272
|]
257273

274+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
258275
type NamesConfig =
259276
{ interfaceNames:RuleConfig<NamingConfig> option
260277
genericTypesNames:RuleConfig<NamingConfig> option
@@ -299,6 +316,7 @@ with
299316
this.internalValuesNames|> Option.bind (constructRuleWithConfig InternalValuesNames.rule) |> Option.toArray
300317
|]
301318

319+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
302320
type NumberOfItemsConfig =
303321
{ maxNumberOfItemsInTuple:RuleConfig<Helper.NumberOfItems.Config> option
304322
maxNumberOfFunctionParameters:RuleConfig<Helper.NumberOfItems.Config> option
@@ -314,6 +332,7 @@ with
314332
this.maxNumberOfBooleanOperatorsInCondition |> Option.bind (constructRuleWithConfig MaxNumberOfBooleanOperatorsInCondition.rule) |> Option.toArray
315333
|]
316334

335+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
317336
type BindingConfig =
318337
{ favourIgnoreOverLetWild:EnabledConfig option
319338
wildcardNamedWithAsPattern:EnabledConfig option
@@ -333,6 +352,7 @@ with
333352
this.favourAsKeyword |> Option.bind (constructRuleIfEnabled FavourAsKeyword.rule) |> Option.toArray
334353
|]
335354

355+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
336356
type ConventionsConfig =
337357
{ recursiveAsyncFunction:EnabledConfig option
338358
avoidTooShortNames:EnabledConfig option
@@ -386,6 +406,7 @@ with
386406
this.indexerAccessorStyleConsistency |> Option.bind (constructRuleWithConfig IndexerAccessorStyleConsistency.rule) |> Option.toArray
387407
|]
388408

409+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
389410
type TypographyConfig =
390411
{ indentation:EnabledConfig option
391412
maxCharactersOnLine:RuleConfig<MaxCharactersOnLine.Config> option
@@ -405,6 +426,8 @@ with
405426
this.noTabCharacters |> Option.bind (constructRuleIfEnabled NoTabCharacters.rule) |> Option.toArray
406427
|]
407428

429+
// </Deprecated>
430+
408431
let private getOrEmptyList hints = Option.defaultValue Array.empty hints
409432

410433
type HintConfig = {
@@ -418,13 +441,21 @@ type GlobalConfig = {
418441

419442
type Configuration =
420443
{ Global:GlobalConfig option
444+
421445
// Deprecated grouped configs. TODO: remove in next major release
446+
447+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
422448
/// DEPRECATED, provide formatting rules at root level.
423449
formatting:FormattingConfig option
450+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
424451
/// DEPRECATED, provide conventions rules at root level.
425452
conventions:ConventionsConfig option
426453
/// DEPRECATED, provide typography rules at root level.
454+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
427455
typography:TypographyConfig option
456+
457+
// </Deprecated>
458+
428459
ignoreFiles:string [] option
429460
Hints:HintConfig option
430461
TypedItemSpacing:RuleConfig<TypedItemSpacing.Config> option
@@ -520,9 +551,13 @@ with
520551
Global = None
521552
ignoreFiles = None
522553
Hints = None
554+
555+
// Deprecated grouped configs. TODO: remove in next major release
523556
formatting = None
524557
conventions = None
525558
typography = None
559+
// </Deprecated>
560+
526561
// Configs for rules.
527562
TypedItemSpacing = None
528563
TypePrefixing = None
@@ -711,9 +746,12 @@ let flattenConfig (config:Configuration) =
711746
let deprecatedAllRules =
712747
Array.concat
713748
[|
749+
// Deprecated grouped configs. TODO: remove in next major release
714750
config.formatting |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat
715751
config.conventions |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat
716752
config.typography |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat
753+
// </Deprecated>
754+
717755
config.Hints |> Option.map (fun config -> HintMatcher.rule { HintMatcher.Config.HintTrie = parseHints (getOrEmptyList config.add) }) |> Option.toArray
718756
|]
719757

0 commit comments

Comments
 (0)