From b4b70ef5828e32c35e66d0d5f0d75fb0ac688e9b Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 26 Jan 2020 21:11:51 +0100 Subject: [PATCH] Extract moduleVisitorSchema in project rules to get better error messages --- src/NoUnusedExports.elm | 23 +++++++++++++---------- src/NoUnusedModules.elm | 13 ++++++++----- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/NoUnusedExports.elm b/src/NoUnusedExports.elm index 8ebd0b3b..2608e965 100644 --- a/src/NoUnusedExports.elm +++ b/src/NoUnusedExports.elm @@ -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 diff --git a/src/NoUnusedModules.elm b/src/NoUnusedModules.elm index bfe8e811..d9efddf6 100644 --- a/src/NoUnusedModules.elm +++ b/src/NoUnusedModules.elm @@ -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