Extract moduleVisitorSchema in project rules to get better error messages

This commit is contained in:
Jeroen Engels 2020-01-26 21:11:51 +01:00
parent 89a3a3d1b4
commit b4b70ef582
2 changed files with 21 additions and 15 deletions

View File

@ -54,16 +54,7 @@ unused modules in your application or package.
rule : Rule
rule =
Rule.newProjectRuleSchema "NoUnused.Exports"
{ moduleVisitorSchema =
\schema ->
schema
|> Scope.addModuleVisitors
{ set = \scope context -> { context | scope = scope }
, get = .scope
}
|> Rule.withModuleDefinitionVisitor moduleDefinitionVisitor
|> Rule.withDeclarationListVisitor declarationListVisitor
|> Rule.withExpressionVisitor expressionVisitor
{ moduleVisitorSchema = moduleVisitorSchema
, initProjectContext = initProjectContext
, fromProjectToModule = fromProjectToModule
, fromModuleToProject = fromModuleToProject
@ -79,6 +70,18 @@ rule =
|> Rule.fromProjectRuleSchema
moduleVisitorSchema : Rule.ModuleRuleSchema {} ModuleContext -> Rule.ModuleRuleSchema { hasAtLeastOneVisitor : () } ModuleContext
moduleVisitorSchema schema =
schema
|> Scope.addModuleVisitors
{ set = \scope context -> { context | scope = scope }
, get = .scope
}
|> Rule.withModuleDefinitionVisitor moduleDefinitionVisitor
|> Rule.withDeclarationListVisitor declarationListVisitor
|> Rule.withExpressionVisitor expressionVisitor
-- CONTEXT

View File

@ -47,11 +47,7 @@ unused modules in your application or package.
rule : Rule
rule =
Rule.newProjectRuleSchema "NoUnused.Modules"
{ moduleVisitorSchema =
\schema ->
schema
|> Rule.withImportVisitor importVisitor
|> Rule.withDeclarationListVisitor declarationListVisitor
{ moduleVisitorSchema = moduleVisitorSchema
, initProjectContext = initProjectContext
, fromProjectToModule = fromProjectToModule
, fromModuleToProject = fromModuleToProject
@ -62,6 +58,13 @@ rule =
|> Rule.fromProjectRuleSchema
moduleVisitorSchema : Rule.ModuleRuleSchema {} ModuleContext -> Rule.ModuleRuleSchema { hasAtLeastOneVisitor : () } ModuleContext
moduleVisitorSchema schema =
schema
|> Rule.withImportVisitor importVisitor
|> Rule.withDeclarationListVisitor declarationListVisitor
-- CONTEXT