@@ -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) >]
159171type TupleFormattingConfig =
160172 { tupleCommaSpacing: EnabledConfig option
161173 tupleIndentation: EnabledConfig option
169181 Option.bind ( constructRuleIfEnabled TupleParentheses.rule) this.tupleParentheses
170182 |]
171183
184+ [<Obsolete( ObsoleteMsg, ObsoleteWarnTreatAsError) >]
172185type PatternMatchFormattingConfig =
173186 { patternMatchClausesOnNewLine: EnabledConfig option
174187 patternMatchOrClausesOnNewLine: EnabledConfig option
184197 Option.bind ( constructRuleIfEnabled PatternMatchExpressionIndentation.rule) this.patternMatchExpressionIndentation
185198 |]
186199
200+ [<Obsolete( ObsoleteMsg, ObsoleteWarnTreatAsError) >]
187201type FormattingConfig =
188202 { typedItemSpacing: RuleConfig < TypedItemSpacing .Config > option
189203 typePrefixing: RuleConfig < TypePrefixing .Config > option
205219 this.patternMatchFormatting |> Option.map ( fun config -> config.Flatten()) |> Option.toArray |> Array.concat
206220 |]
207221
222+ [<Obsolete( ObsoleteMsg, ObsoleteWarnTreatAsError) >]
208223type RaiseWithTooManyArgsConfig =
209224 { failwithBadUsage: EnabledConfig option
210225 raiseWithSingleArgument: EnabledConfig option
224239 this.failwithfWithArgumentsMatchingFormatString |> Option.bind ( constructRuleIfEnabled FailwithfWithArgumentsMatchingFormatString.rule) |> Option.toArray
225240 |]
226241
242+ [<Obsolete( ObsoleteMsg, ObsoleteWarnTreatAsError) >]
227243type SourceLengthConfig =
228244 { maxLinesInLambdaFunction: RuleConfig < Helper .SourceLength .Config > option
229245 maxLinesInMatchLambdaFunction: RuleConfig < Helper .SourceLength .Config > option
255271 this.maxLinesInClass |> Option.bind ( constructRuleWithConfig MaxLinesInClass.rule) |> Option.toArray
256272 |]
257273
274+ [<Obsolete( ObsoleteMsg, ObsoleteWarnTreatAsError) >]
258275type NamesConfig =
259276 { interfaceNames: RuleConfig < NamingConfig > option
260277 genericTypesNames: RuleConfig < NamingConfig > option
299316 this.internalValuesNames|> Option.bind ( constructRuleWithConfig InternalValuesNames.rule) |> Option.toArray
300317 |]
301318
319+ [<Obsolete( ObsoleteMsg, ObsoleteWarnTreatAsError) >]
302320type NumberOfItemsConfig =
303321 { maxNumberOfItemsInTuple: RuleConfig < Helper .NumberOfItems .Config > option
304322 maxNumberOfFunctionParameters: RuleConfig < Helper .NumberOfItems .Config > option
314332 this.maxNumberOfBooleanOperatorsInCondition |> Option.bind ( constructRuleWithConfig MaxNumberOfBooleanOperatorsInCondition.rule) |> Option.toArray
315333 |]
316334
335+ [<Obsolete( ObsoleteMsg, ObsoleteWarnTreatAsError) >]
317336type BindingConfig =
318337 { favourIgnoreOverLetWild: EnabledConfig option
319338 wildcardNamedWithAsPattern: EnabledConfig option
333352 this.favourAsKeyword |> Option.bind ( constructRuleIfEnabled FavourAsKeyword.rule) |> Option.toArray
334353 |]
335354
355+ [<Obsolete( ObsoleteMsg, ObsoleteWarnTreatAsError) >]
336356type ConventionsConfig =
337357 { recursiveAsyncFunction: EnabledConfig option
338358 avoidTooShortNames: EnabledConfig option
386406 this.indexerAccessorStyleConsistency |> Option.bind ( constructRuleWithConfig IndexerAccessorStyleConsistency.rule) |> Option.toArray
387407 |]
388408
409+ [<Obsolete( ObsoleteMsg, ObsoleteWarnTreatAsError) >]
389410type TypographyConfig =
390411 { indentation: EnabledConfig option
391412 maxCharactersOnLine: RuleConfig < MaxCharactersOnLine .Config > option
405426 this.noTabCharacters |> Option.bind ( constructRuleIfEnabled NoTabCharacters.rule) |> Option.toArray
406427 |]
407428
429+ // </Deprecated>
430+
408431let private getOrEmptyList hints = Option.defaultValue Array.empty hints
409432
410433type HintConfig = {
@@ -418,13 +441,21 @@ type GlobalConfig = {
418441
419442type 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