mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-24 18:23:09 +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
|
||||||
rule =
|
rule =
|
||||||
Rule.newMultiSchema "NoUnused.Modules"
|
Rule.newMultiSchema "NoUnused.Modules"
|
||||||
{ elmJsonVisitors = [ elmJsonVisitor ]
|
{ dependenciesVisitors = []
|
||||||
, dependenciesVisitors = []
|
|
||||||
, moduleVisitorSchema = moduleVisitorSchema
|
, moduleVisitorSchema = moduleVisitorSchema
|
||||||
, context =
|
, context =
|
||||||
{ initGlobalContext = initGlobalContext
|
{ initGlobalContext = initGlobalContext
|
||||||
@ -58,6 +57,7 @@ rule =
|
|||||||
}
|
}
|
||||||
, finalEvaluation = finalEvaluationForProject
|
, finalEvaluation = finalEvaluationForProject
|
||||||
}
|
}
|
||||||
|
|> Rule.withMultiElmJsonVisitor elmJsonVisitor
|
||||||
|> Rule.fromMultiSchema
|
|> Rule.fromMultiSchema
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ module Review.Rule exposing
|
|||||||
, newMultiSchema, fromMultiSchema, newFileVisitorSchema
|
, newMultiSchema, fromMultiSchema, newFileVisitorSchema
|
||||||
, FileKey, errorForFile
|
, FileKey, errorForFile
|
||||||
, ReviewResult(..)
|
, ReviewResult(..)
|
||||||
|
, withMultiElmJsonVisitor
|
||||||
)
|
)
|
||||||
|
|
||||||
{-| This module contains functions that are used for writing rules.
|
{-| This module contains functions that are used for writing rules.
|
||||||
@ -549,8 +550,7 @@ type MultiSchema globalContext moduleContext
|
|||||||
newMultiSchema :
|
newMultiSchema :
|
||||||
String
|
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
|
, moduleVisitorSchema : Schema ForLookingAtSeveralFiles { hasNoVisitor : () } moduleContext -> Schema ForLookingAtSeveralFiles { hasAtLeastOneVisitor : () } moduleContext
|
||||||
, context :
|
, context :
|
||||||
{ initGlobalContext : globalContext
|
{ initGlobalContext : globalContext
|
||||||
@ -561,11 +561,11 @@ newMultiSchema :
|
|||||||
, finalEvaluation : globalContext -> List Error
|
, finalEvaluation : globalContext -> List Error
|
||||||
}
|
}
|
||||||
-> MultiSchema globalContext moduleContext
|
-> MultiSchema globalContext moduleContext
|
||||||
newMultiSchema name_ { context, elmJsonVisitors, dependenciesVisitors, moduleVisitorSchema, finalEvaluation } =
|
newMultiSchema name_ { context, dependenciesVisitors, moduleVisitorSchema, finalEvaluation } =
|
||||||
MultiSchema
|
MultiSchema
|
||||||
{ name = name_
|
{ name = name_
|
||||||
, context = context
|
, context = context
|
||||||
, elmJsonVisitors = elmJsonVisitors
|
, elmJsonVisitors = []
|
||||||
, dependenciesVisitors = dependenciesVisitors
|
, dependenciesVisitors = dependenciesVisitors
|
||||||
, moduleVisitorSchema = moduleVisitorSchema
|
, moduleVisitorSchema = moduleVisitorSchema
|
||||||
, finalEvaluationFn = finalEvaluation
|
, finalEvaluationFn = finalEvaluation
|
||||||
@ -718,6 +718,16 @@ moduleNameNode node =
|
|||||||
data.moduleName
|
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.
|
{-| Concatenate the errors of the previous step and of the last step.
|
||||||
-}
|
-}
|
||||||
makeFinalEvaluation : List (context -> List Error) -> ( List Error, context ) -> List Error
|
makeFinalEvaluation : List (context -> List Error) -> ( List Error, context ) -> List Error
|
||||||
|
Loading…
Reference in New Issue
Block a user