Skip to content

Commit

Permalink
Configuration,Tests.Console: re-enabled regression test
Browse files Browse the repository at this point in the history
Re-enabled regression test for TypePrefixing rule with old
config format and made it pass.
  • Loading branch information
webwarrior-ws committed Jan 2, 2024
1 parent 5e68892 commit e3ea85b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/FSharpLint.Core/Application/Configuration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ let constructRuleWithConfig rule ruleConfig =
else
None

let constructTypePrefixingRuleWithConfig rule (ruleConfig: RuleConfig<TypePrefixing.Config>) =
if ruleConfig.Enabled then
let config = ruleConfig.Config |> Option.defaultValue { Mode = TypePrefixing.Mode.Hybrid }
Some(rule config)
else
None

type TupleFormattingConfig =
{ tupleCommaSpacing:EnabledConfig option
tupleIndentation:EnabledConfig option
Expand Down Expand Up @@ -175,7 +182,7 @@ with
member this.Flatten() =
[|
this.typedItemSpacing |> Option.bind (constructRuleWithConfig TypedItemSpacing.rule) |> Option.toArray
this.typePrefixing |> Option.bind (constructRuleWithConfig TypePrefixing.rule) |> Option.toArray
this.typePrefixing |> Option.bind (constructTypePrefixingRuleWithConfig TypePrefixing.rule) |> Option.toArray
this.unionDefinitionIndentation |> Option.bind (constructRuleIfEnabled UnionDefinitionIndentation.rule) |> Option.toArray
this.moduleDeclSpacing |> Option.bind (constructRuleIfEnabled ModuleDeclSpacing.rule) |> Option.toArray
this.classMemberSpacing |> Option.bind (constructRuleIfEnabled ClassMemberSpacing.rule) |> Option.toArray
Expand Down Expand Up @@ -628,7 +635,7 @@ let flattenConfig (config:Configuration) =
let allRules =
[|
config.TypedItemSpacing |> Option.bind (constructRuleWithConfig TypedItemSpacing.rule)
config.TypePrefixing |> Option.bind (constructRuleWithConfig TypePrefixing.rule)
config.TypePrefixing |> Option.bind (constructTypePrefixingRuleWithConfig TypePrefixing.rule)
config.UnionDefinitionIndentation |> Option.bind (constructRuleIfEnabled UnionDefinitionIndentation.rule)
config.ModuleDeclSpacing |> Option.bind (constructRuleIfEnabled ModuleDeclSpacing.rule)
config.ClassMemberSpacing |> Option.bind (constructRuleIfEnabled ClassMemberSpacing.rule)
Expand Down
2 changes: 0 additions & 2 deletions tests/FSharpLint.Console.Tests/TestApp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ type TestConsoleApplication() =
Assert.AreEqual(0, returnCode)
Assert.AreEqual(Set.empty, errors)

(* disabling regression test for now until I finish the development of new config
[<Test>]
*)
member __.``Regression test: typePrefixing rule with old config format should still work``() =
let fileContent = """
{
Expand Down

0 comments on commit e3ea85b

Please sign in to comment.