Skip to content

Commit 5773c92

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 9e57659 commit 5773c92

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
@@ -120,6 +120,18 @@ let constructTypePrefixingRuleWithConfig rule (ruleConfig: RuleConfig<TypePrefix
120120
else
121121
None
122122

123+
124+
// Deprecated grouped configs. TODO: remove in next major release
125+
126+
[<Literal>]
127+
let private ObsoleteMsg = "Please provide formatting rules at root level. This type will be removed in the near future."
128+
[<Literal>]
129+
let private ObsoleteWarnTreatAsError = false
130+
131+
// to be able to use our own types that we mark as Obsolete
132+
#nowarn "44"
133+
134+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
123135
type TupleFormattingConfig =
124136
{ tupleCommaSpacing:EnabledConfig option
125137
tupleIndentation:EnabledConfig option
@@ -133,6 +145,7 @@ with
133145
Option.bind (constructRuleIfEnabled TupleParentheses.rule) this.tupleParentheses
134146
|]
135147

148+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
136149
type PatternMatchFormattingConfig =
137150
{ patternMatchClausesOnNewLine:EnabledConfig option
138151
patternMatchOrClausesOnNewLine:EnabledConfig option
@@ -148,6 +161,7 @@ with
148161
Option.bind (constructRuleIfEnabled PatternMatchExpressionIndentation.rule) this.patternMatchExpressionIndentation
149162
|]
150163

164+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
151165
type FormattingConfig =
152166
{ typedItemSpacing:RuleConfig<TypedItemSpacing.Config> option
153167
typePrefixing:RuleConfig<TypePrefixing.Config> option
@@ -169,6 +183,7 @@ with
169183
this.patternMatchFormatting |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat
170184
|]
171185

186+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
172187
type RaiseWithTooManyArgsConfig =
173188
{ failwithBadUsage:EnabledConfig option
174189
raiseWithSingleArgument:EnabledConfig option
@@ -188,6 +203,7 @@ with
188203
this.failwithfWithArgumentsMatchingFormatString |> Option.bind (constructRuleIfEnabled FailwithfWithArgumentsMatchingFormatString.rule) |> Option.toArray
189204
|]
190205

206+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
191207
type SourceLengthConfig =
192208
{ maxLinesInLambdaFunction:RuleConfig<Helper.SourceLength.Config> option
193209
maxLinesInMatchLambdaFunction:RuleConfig<Helper.SourceLength.Config> option
@@ -219,6 +235,7 @@ with
219235
this.maxLinesInClass |> Option.bind (constructRuleWithConfig MaxLinesInClass.rule) |> Option.toArray
220236
|]
221237

238+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
222239
type NamesConfig =
223240
{ interfaceNames:RuleConfig<NamingConfig> option
224241
genericTypesNames:RuleConfig<NamingConfig> option
@@ -263,6 +280,7 @@ with
263280
this.internalValuesNames|> Option.bind (constructRuleWithConfig InternalValuesNames.rule) |> Option.toArray
264281
|]
265282

283+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
266284
type NumberOfItemsConfig =
267285
{ maxNumberOfItemsInTuple:RuleConfig<Helper.NumberOfItems.Config> option
268286
maxNumberOfFunctionParameters:RuleConfig<Helper.NumberOfItems.Config> option
@@ -278,6 +296,7 @@ with
278296
this.maxNumberOfBooleanOperatorsInCondition |> Option.bind (constructRuleWithConfig MaxNumberOfBooleanOperatorsInCondition.rule) |> Option.toArray
279297
|]
280298

299+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
281300
type BindingConfig =
282301
{ favourIgnoreOverLetWild:EnabledConfig option
283302
wildcardNamedWithAsPattern:EnabledConfig option
@@ -297,6 +316,7 @@ with
297316
this.favourAsKeyword |> Option.bind (constructRuleIfEnabled FavourAsKeyword.rule) |> Option.toArray
298317
|]
299318

319+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
300320
type ConventionsConfig =
301321
{ recursiveAsyncFunction:EnabledConfig option
302322
avoidTooShortNames:EnabledConfig option
@@ -348,6 +368,7 @@ with
348368
this.ensureTailCallDiagnosticsInRecursiveFunctions |> Option.bind (constructRuleIfEnabled EnsureTailCallDiagnosticsInRecursiveFunctions.rule) |> Option.toArray
349369
|]
350370

371+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
351372
type TypographyConfig =
352373
{ indentation:EnabledConfig option
353374
maxCharactersOnLine:RuleConfig<MaxCharactersOnLine.Config> option
@@ -367,6 +388,8 @@ with
367388
this.noTabCharacters |> Option.bind (constructRuleIfEnabled NoTabCharacters.rule) |> Option.toArray
368389
|]
369390

391+
// </Deprecated>
392+
370393
let private getOrEmptyList hints = Option.defaultValue Array.empty hints
371394

372395
type HintConfig = {
@@ -380,13 +403,21 @@ type GlobalConfig = {
380403

381404
type Configuration =
382405
{ Global:GlobalConfig option
406+
383407
// Deprecated grouped configs. TODO: remove in next major release
408+
409+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
384410
/// DEPRECATED, provide formatting rules at root level.
385411
formatting:FormattingConfig option
412+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
386413
/// DEPRECATED, provide conventions rules at root level.
387414
conventions:ConventionsConfig option
388415
/// DEPRECATED, provide typography rules at root level.
416+
[<Obsolete(ObsoleteMsg, ObsoleteWarnTreatAsError)>]
389417
typography:TypographyConfig option
418+
419+
// </Deprecated>
420+
390421
ignoreFiles:string [] option
391422
Hints:HintConfig option
392423
TypedItemSpacing:RuleConfig<TypedItemSpacing.Config> option
@@ -480,9 +511,13 @@ with
480511
Global = None
481512
ignoreFiles = None
482513
Hints = None
514+
515+
// Deprecated grouped configs. TODO: remove in next major release
483516
formatting = None
484517
conventions = None
485518
typography = None
519+
// </Deprecated>
520+
486521
// Configs for rules.
487522
TypedItemSpacing = None
488523
TypePrefixing = None
@@ -669,9 +704,12 @@ let flattenConfig (config:Configuration) =
669704
let deprecatedAllRules =
670705
Array.concat
671706
[|
707+
// Deprecated grouped configs. TODO: remove in next major release
672708
config.formatting |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat
673709
config.conventions |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat
674710
config.typography |> Option.map (fun config -> config.Flatten()) |> Option.toArray |> Array.concat
711+
// </Deprecated>
712+
675713
config.Hints |> Option.map (fun config -> HintMatcher.rule { HintMatcher.Config.HintTrie = parseHints (getOrEmptyList config.add) }) |> Option.toArray
676714
|]
677715

0 commit comments

Comments
 (0)