mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-23 17:53:35 +03:00
Add Rule.withIsInSourceDirectories
This commit is contained in:
parent
d11d4853f9
commit
e1e522eafb
@ -13,7 +13,7 @@ module Review.Rule exposing
|
||||
, withFinalModuleEvaluation
|
||||
, withElmJsonModuleVisitor, withReadmeModuleVisitor, withDependenciesModuleVisitor
|
||||
, ProjectRuleSchema, newProjectRuleSchema, fromProjectRuleSchema, withModuleVisitor, withModuleContext, withModuleContextUsingContextCreator, withElmJsonProjectVisitor, withReadmeProjectVisitor, withDependenciesProjectVisitor, withFinalProjectEvaluation, withContextFromImportedModules
|
||||
, ContextCreator, initContextCreator, withModuleName, withModuleNameNode, withFilePath, withModuleNameLookupTable, withModuleKey, withSourceCodeExtractor
|
||||
, ContextCreator, initContextCreator, withModuleName, withModuleNameNode, withIsInSourceDirectories, withFilePath, withModuleNameLookupTable, withModuleKey, withSourceCodeExtractor
|
||||
, Metadata, withMetadata, moduleNameFromMetadata, moduleNameNodeFromMetadata, isInSourceDirectories
|
||||
, Error, error, errorWithFix, ModuleKey, errorForModule, errorForModuleWithFix, ElmJsonKey, errorForElmJson, errorForElmJsonWithFix, ReadmeKey, errorForReadme, errorForReadmeWithFix
|
||||
, globalError, configurationError
|
||||
@ -224,7 +224,7 @@ first, as they are in practice a simpler version of project rules.
|
||||
|
||||
## Requesting more information
|
||||
|
||||
@docs ContextCreator, initContextCreator, withModuleName, withModuleNameNode, withFilePath, withModuleNameLookupTable, withModuleKey, withSourceCodeExtractor
|
||||
@docs ContextCreator, initContextCreator, withModuleName, withModuleNameNode, withIsInSourceDirectories, withFilePath, withModuleNameLookupTable, withModuleKey, withSourceCodeExtractor
|
||||
@docs Metadata, withMetadata, moduleNameFromMetadata, moduleNameNodeFromMetadata, isInSourceDirectories
|
||||
|
||||
|
||||
@ -5091,6 +5091,28 @@ withModuleNameNode (ContextCreator fn requestedData) =
|
||||
requestedData
|
||||
|
||||
|
||||
{-| Request to know whether the current module is in the "source-directories" of the project. You can use this information to
|
||||
know whether the module is part of the tests or of the production code.
|
||||
|
||||
contextCreator : Rule.ContextCreator () Context
|
||||
contextCreator =
|
||||
Rule.initContextCreator
|
||||
(\isInSourceDirectories () ->
|
||||
{ isInSourceDirectories = isInSourceDirectories
|
||||
|
||||
-- ...other fields
|
||||
}
|
||||
)
|
||||
|> Rule.withIsInSourceDirectories
|
||||
|
||||
-}
|
||||
withIsInSourceDirectories : ContextCreator Bool (from -> to) -> ContextCreator from to
|
||||
withIsInSourceDirectories (ContextCreator fn requestedData) =
|
||||
ContextCreator
|
||||
(\data -> fn data (isInSourceDirectories data.metadata))
|
||||
requestedData
|
||||
|
||||
|
||||
{-| Requests the module name lookup table for the types and functions inside a module.
|
||||
|
||||
When encountering a `Expression.FunctionOrValue ModuleName String` (among other nodes where we refer to a function or value),
|
||||
|
Loading…
Reference in New Issue
Block a user