diff --git a/src/NoUnusedModules.elm b/src/NoUnusedModules.elm index d130c190..e717a7cc 100644 --- a/src/NoUnusedModules.elm +++ b/src/NoUnusedModules.elm @@ -47,8 +47,7 @@ unused modules in your application or package. rule : Rule rule = Rule.newMultiSchema "NoUnused.Modules" - { elmJsonVisitors = [ elmJsonVisitor ] - , dependenciesVisitors = [] + { dependenciesVisitors = [] , moduleVisitorSchema = moduleVisitorSchema , context = { initGlobalContext = initGlobalContext @@ -58,6 +57,7 @@ rule = } , finalEvaluation = finalEvaluationForProject } + |> Rule.withMultiElmJsonVisitor elmJsonVisitor |> Rule.fromMultiSchema diff --git a/src/Review/Rule.elm b/src/Review/Rule.elm index 3329a79c..af82b658 100644 --- a/src/Review/Rule.elm +++ b/src/Review/Rule.elm @@ -10,6 +10,7 @@ module Review.Rule exposing , newMultiSchema, fromMultiSchema, newFileVisitorSchema , FileKey, errorForFile , ReviewResult(..) + , withMultiElmJsonVisitor ) {-| This module contains functions that are used for writing rules. @@ -549,8 +550,7 @@ type MultiSchema globalContext moduleContext newMultiSchema : String -> - { elmJsonVisitors : List (Maybe Elm.Project.Project -> globalContext -> globalContext) - , dependenciesVisitors : List (Dict String Elm.Docs.Module -> globalContext -> globalContext) + { dependenciesVisitors : List (Dict String Elm.Docs.Module -> globalContext -> globalContext) , moduleVisitorSchema : Schema ForLookingAtSeveralFiles { hasNoVisitor : () } moduleContext -> Schema ForLookingAtSeveralFiles { hasAtLeastOneVisitor : () } moduleContext , context : { initGlobalContext : globalContext @@ -561,11 +561,11 @@ newMultiSchema : , finalEvaluation : globalContext -> List Error } -> MultiSchema globalContext moduleContext -newMultiSchema name_ { context, elmJsonVisitors, dependenciesVisitors, moduleVisitorSchema, finalEvaluation } = +newMultiSchema name_ { context, dependenciesVisitors, moduleVisitorSchema, finalEvaluation } = MultiSchema { name = name_ , context = context - , elmJsonVisitors = elmJsonVisitors + , elmJsonVisitors = [] , dependenciesVisitors = dependenciesVisitors , moduleVisitorSchema = moduleVisitorSchema , finalEvaluationFn = finalEvaluation @@ -718,6 +718,16 @@ moduleNameNode node = data.moduleName +{-| TODO documentation +-} +withMultiElmJsonVisitor : + (Maybe Elm.Project.Project -> globalContext -> globalContext) + -> MultiSchema globalContext moduleContext + -> MultiSchema globalContext moduleContext +withMultiElmJsonVisitor visitor (MultiSchema schema) = + MultiSchema { schema | elmJsonVisitors = visitor :: schema.elmJsonVisitors } + + {-| Concatenate the errors of the previous step and of the last step. -} makeFinalEvaluation : List (context -> List Error) -> ( List Error, context ) -> List Error