mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-24 18:23:09 +03:00
Fix error being reported for their module instead of the external file
This commit is contained in:
parent
3d1001d5d2
commit
3621447a82
@ -550,7 +550,7 @@ computeErrors (ModuleRuleSchema schema) project initialContext =
|
||||
|> accumulateWithListOfVisitors schema.declarationListVisitors module_.ast.declarations
|
||||
|> accumulateList (visitDeclaration declarationVisitors expressionVisitors) module_.ast.declarations
|
||||
|> makeFinalEvaluation schema.finalEvaluationFns
|
||||
|> List.map (\(Error err) -> Error { err | ruleName = schema.name, filePath = module_.path })
|
||||
|> List.map (setRuleName schema.name >> setFilePathIfUnset module_)
|
||||
|> List.reverse
|
||||
|
||||
|
||||
@ -771,7 +771,7 @@ traverseAllModulesInParallel (ProjectRuleSchema schema) startCache project =
|
||||
module_
|
||||
in
|
||||
{ source = module_.source
|
||||
, errors = List.map (\(Error err) -> Error { err | filePath = module_.path }) fileErrors
|
||||
, errors = List.map (setFilePathIfUnset module_) fileErrors
|
||||
, context =
|
||||
schema.context.fromModuleToProject
|
||||
fileKey
|
||||
@ -812,7 +812,7 @@ traverseAllModulesInParallel (ProjectRuleSchema schema) startCache project =
|
||||
|> List.map Tuple.second
|
||||
|> List.foldl schema.context.foldProjectContexts initialContext
|
||||
|> makeFinalEvaluationForProject schema.finalEvaluationFns
|
||||
|> List.map (\(Error err) -> Error { err | ruleName = schema.name })
|
||||
|> List.map (setRuleName schema.name)
|
||||
]
|
||||
in
|
||||
( errors, Rule schema.name (runProjectRule (ProjectRuleSchema schema) newCache) )
|
||||
@ -891,7 +891,7 @@ traverseImportedModulesFirst (ProjectRuleSchema schema) startCache project =
|
||||
module_
|
||||
in
|
||||
{ source = module_.source
|
||||
, errors = List.map (\(Error err) -> Error { err | filePath = module_.path }) fileErrors
|
||||
, errors = List.map (setFilePathIfUnset module_) fileErrors
|
||||
, context =
|
||||
schema.context.fromModuleToProject
|
||||
fileKey
|
||||
@ -929,7 +929,7 @@ traverseImportedModulesFirst (ProjectRuleSchema schema) startCache project =
|
||||
|> List.map Tuple.second
|
||||
|> List.foldl schema.context.foldProjectContexts initialContext
|
||||
|> makeFinalEvaluationForProject schema.finalEvaluationFns
|
||||
|> List.map (\(Error err) -> Error { err | ruleName = schema.name })
|
||||
|> List.map (setRuleName schema.name)
|
||||
]
|
||||
in
|
||||
( errors, Rule schema.name (runProjectRule (ProjectRuleSchema schema) newCache) )
|
||||
@ -939,6 +939,25 @@ traverseImportedModulesFirst (ProjectRuleSchema schema) startCache project =
|
||||
( [], Rule schema.name (runProjectRule (ProjectRuleSchema schema) startCache) )
|
||||
|
||||
|
||||
setRuleName : String -> Error -> Error
|
||||
setRuleName ruleName (Error err) =
|
||||
Error { err | ruleName = ruleName }
|
||||
|
||||
|
||||
setFilePathIfUnset : ProjectModule -> Error -> Error
|
||||
setFilePathIfUnset module_ (Error err) =
|
||||
Error
|
||||
{ err
|
||||
| filePath =
|
||||
case err.filePath of
|
||||
"" ->
|
||||
module_.path
|
||||
|
||||
_ ->
|
||||
err.filePath
|
||||
}
|
||||
|
||||
|
||||
computeModuleAndCacheResult :
|
||||
Dict ModuleName ProjectModule
|
||||
-> Graph ModuleName ()
|
||||
|
Loading…
Reference in New Issue
Block a user