elm-review/phantom-type-tests/WithModuleContext_AtMostOnce.elm
2020-03-19 23:06:04 +01:00

31 lines
993 B
Elm

module WithModuleContext_AtMostOnce exposing (rule)
{-| We want to forbid `Rule.withModuleContext` from being called twice.
-}
import Review.Rule as Rule exposing (Rule)
rule : Rule
rule =
Rule.newProjectRuleSchema "WithModuleContext_AtMostOnce" ()
|> Rule.withModuleVisitor moduleVisitor
|> Rule.withModuleContext
{ fromProjectToModule = \_ _ () -> ()
, fromModuleToProject = \_ _ () -> ()
, foldProjectContexts = \_ () -> ()
}
|> Rule.withModuleContext
{ fromProjectToModule = \_ _ () -> ()
, fromModuleToProject = \_ _ () -> ()
, foldProjectContexts = \_ () -> ()
}
|> Rule.withFinalProjectEvaluation (\_ -> [])
|> Rule.fromProjectRuleSchema
moduleVisitor : Rule.ModuleRuleSchema {} () -> Rule.ModuleRuleSchema { hasAtLeastOneVisitor : () } ()
moduleVisitor schema =
schema
|> Rule.withModuleDefinitionVisitor (\_ () -> ( [], () ))