mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-24 02:02:29 +03:00
Add builder function to add an elm.json visitor for multi rules
This commit is contained in:
parent
a63e7afb83
commit
3fec3aa1d2
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user