mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-23 17:53:35 +03:00
Make it not possible to use withModuleVisitor after withModuleContext
This commit is contained in:
parent
06da24e1aa
commit
abac9224bc
@ -11,12 +11,18 @@ This function cannot handle the argument sent through the (|>) pipe:
|
|||||||
|
|
||||||
The argument is:
|
The argument is:
|
||||||
|
|
||||||
Rule.ProjectRuleSchema () () {}
|
Rule.ProjectRuleSchema () () { canAddModuleVisitor : () }
|
||||||
|
|
||||||
But (|>) is piping it to a function that expects:
|
But (|>) is piping it to a function that expects:
|
||||||
|
|
||||||
Rule.ProjectRuleSchema
|
Rule.ProjectRuleSchema
|
||||||
()
|
()
|
||||||
()
|
()
|
||||||
{ schemaState | withModuleContext : Rule.Required }
|
{ a | canAddModuleVisitor : (), withModuleContext : Rule.Required }
|
||||||
|
|
||||||
|
Hint: Seems like a record field typo. Maybe withModuleContext should be
|
||||||
|
canAddModuleVisitor?
|
||||||
|
|
||||||
|
Hint: Can more type annotations be added? Type annotations always help me give
|
||||||
|
more specific messages, and I think they could help a lot in this case!
|
||||||
|
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
module No_WithModuleVisitor_After_WithModuleContext exposing (rule)
|
||||||
|
|
||||||
|
{-| We want to forbid using `Rule.withModuleVisitor` after having used `withModuleContext`.
|
||||||
|
-}
|
||||||
|
|
||||||
|
import Review.Rule as Rule exposing (Rule)
|
||||||
|
|
||||||
|
|
||||||
|
rule : Rule
|
||||||
|
rule =
|
||||||
|
Rule.newProjectRuleSchema "No_WithModuleVisitor_After_WithModuleContext" ()
|
||||||
|
|> Rule.withModuleVisitor moduleVisitor
|
||||||
|
|> Rule.withModuleContext
|
||||||
|
{ fromProjectToModule = \_ _ () -> ()
|
||||||
|
, fromModuleToProject = \_ _ () -> ()
|
||||||
|
, foldProjectContexts = \_ () -> ()
|
||||||
|
}
|
||||||
|
|> Rule.withModuleVisitor moduleVisitor
|
||||||
|
|> Rule.withFinalProjectEvaluation (\_ -> [])
|
||||||
|
|> Rule.fromProjectRuleSchema
|
||||||
|
|
||||||
|
|
||||||
|
moduleVisitor : Rule.ModuleRuleSchema {} () -> Rule.ModuleRuleSchema { hasAtLeastOneVisitor : () } ()
|
||||||
|
moduleVisitor schema =
|
||||||
|
schema
|
||||||
|
|> Rule.withModuleDefinitionVisitor (\_ () -> ( [], () ))
|
@ -17,12 +17,18 @@ This function cannot handle the argument sent through the (|>) pipe:
|
|||||||
|
|
||||||
The argument is:
|
The argument is:
|
||||||
|
|
||||||
Rule.ProjectRuleSchema () () {}
|
Rule.ProjectRuleSchema () () { canAddModuleVisitor : () }
|
||||||
|
|
||||||
But (|>) is piping it to a function that expects:
|
But (|>) is piping it to a function that expects:
|
||||||
|
|
||||||
Rule.ProjectRuleSchema
|
Rule.ProjectRuleSchema
|
||||||
()
|
()
|
||||||
()
|
()
|
||||||
{ schemaState | withModuleContext : Rule.Required }
|
{ a | canAddModuleVisitor : (), withModuleContext : Rule.Required }
|
||||||
|
|
||||||
|
Hint: Seems like a record field typo. Maybe withModuleContext should be
|
||||||
|
canAddModuleVisitor?
|
||||||
|
|
||||||
|
Hint: Can more type annotations be added? Type annotations always help me give
|
||||||
|
more specific messages, and I think they could help a lot in this case!
|
||||||
|
|
||||||
|
@ -925,7 +925,7 @@ You can't use [`withElmJsonModuleVisitor`](#withElmJsonModuleVisitor) or [`withD
|
|||||||
in project rules. Instead, you should use [`withElmJsonProjectVisitor`](#withElmJsonProjectVisitor) or [`withDependenciesProjectVisitor`](#withDependenciesProjectVisitor).
|
in project rules. Instead, you should use [`withElmJsonProjectVisitor`](#withElmJsonProjectVisitor) or [`withDependenciesProjectVisitor`](#withDependenciesProjectVisitor).
|
||||||
|
|
||||||
-}
|
-}
|
||||||
newProjectRuleSchema : String -> projectContext -> ProjectRuleSchema projectContext moduleContext {}
|
newProjectRuleSchema : String -> projectContext -> ProjectRuleSchema projectContext moduleContext { canAddModuleVisitor : () }
|
||||||
newProjectRuleSchema name_ initialProjectContext =
|
newProjectRuleSchema name_ initialProjectContext =
|
||||||
ProjectRuleSchema
|
ProjectRuleSchema
|
||||||
{ name = name_
|
{ name = name_
|
||||||
@ -962,8 +962,8 @@ fromProjectRuleSchema (ProjectRuleSchema schema) =
|
|||||||
-}
|
-}
|
||||||
withModuleVisitor :
|
withModuleVisitor :
|
||||||
(ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext)
|
(ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext)
|
||||||
-> ProjectRuleSchema projectContext moduleContext schemaState
|
-> ProjectRuleSchema projectContext moduleContext { schemaState | canAddModuleVisitor : () }
|
||||||
-> ProjectRuleSchema projectContext moduleContext { schemaState | withModuleContext : Required }
|
-> ProjectRuleSchema projectContext moduleContext { schemaState | canAddModuleVisitor : (), withModuleContext : Required }
|
||||||
withModuleVisitor visitor (ProjectRuleSchema schema) =
|
withModuleVisitor visitor (ProjectRuleSchema schema) =
|
||||||
let
|
let
|
||||||
previousModuleVisitors : List (ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext)
|
previousModuleVisitors : List (ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext)
|
||||||
@ -994,7 +994,7 @@ withModuleContext :
|
|||||||
, fromModuleToProject : ModuleKey -> Node ModuleName -> moduleContext -> projectContext
|
, fromModuleToProject : ModuleKey -> Node ModuleName -> moduleContext -> projectContext
|
||||||
, foldProjectContexts : projectContext -> projectContext -> projectContext
|
, foldProjectContexts : projectContext -> projectContext -> projectContext
|
||||||
}
|
}
|
||||||
-> ProjectRuleSchema projectContext moduleContext { schemaState | withModuleContext : Required }
|
-> ProjectRuleSchema projectContext moduleContext { schemaState | canAddModuleVisitor : (), withModuleContext : Required }
|
||||||
-> ProjectRuleSchema projectContext moduleContext schemaState
|
-> ProjectRuleSchema projectContext moduleContext schemaState
|
||||||
withModuleContext moduleContext (ProjectRuleSchema schema) =
|
withModuleContext moduleContext (ProjectRuleSchema schema) =
|
||||||
let
|
let
|
||||||
|
@ -167,8 +167,8 @@ emptyScope =
|
|||||||
|
|
||||||
|
|
||||||
addProjectVisitors :
|
addProjectVisitors :
|
||||||
Rule.ProjectRuleSchema { projectContext | scope : ProjectContext } { moduleContext | scope : ModuleContext } schemaState
|
Rule.ProjectRuleSchema { projectContext | scope : ProjectContext } { moduleContext | scope : ModuleContext } { schemaState | canAddModuleVisitor : () }
|
||||||
-> Rule.ProjectRuleSchema { projectContext | scope : ProjectContext } { moduleContext | scope : ModuleContext } { schemaState | withModuleContext : Rule.Required }
|
-> Rule.ProjectRuleSchema { projectContext | scope : ProjectContext } { moduleContext | scope : ModuleContext } { schemaState | canAddModuleVisitor : (), withModuleContext : Rule.Required }
|
||||||
addProjectVisitors schema =
|
addProjectVisitors schema =
|
||||||
schema
|
schema
|
||||||
|> Rule.withContextFromImportedModules
|
|> Rule.withContextFromImportedModules
|
||||||
|
Loading…
Reference in New Issue
Block a user