elm-review/phantom-type-tests/WithModuleContext_AtMostOnce.elm

31 lines
993 B
Elm
Raw Normal View History

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 (\_ () -> ( [], () ))