mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-24 10:14:04 +03:00
Rename withElmJsonVisitor to withModuleElmJsonVisitor
This commit is contained in:
parent
a5b47cdc73
commit
0cada05fe3
@ -1,6 +1,6 @@
|
|||||||
module NoWithInitialContextAfterHavingAddedAVisitor exposing (rule)
|
module NoWithInitialContextAfterHavingAddedAVisitor exposing (rule)
|
||||||
|
|
||||||
{-| We want to forbid module visitors from using `withElmJsonVisitor`.
|
{-| We want to forbid module visitors from using `withModuleElmJsonVisitor`.
|
||||||
|
|
||||||
|
|
||||||
# Rule
|
# Rule
|
||||||
|
@ -271,7 +271,8 @@ type alias ElmJson =
|
|||||||
|
|
||||||
{-| Add the content of the `elm.json` file to the project details, making it
|
{-| Add the content of the `elm.json` file to the project details, making it
|
||||||
available for rules to access using
|
available for rules to access using
|
||||||
[`Review.Rule.withElmJsonVisitor`](./Review-Rule#withElmJsonVisitor).
|
[`Review.Rule.withModuleElmJsonVisitor`](./Review-Rule#withModuleElmJsonVisitor) and
|
||||||
|
[`Review.Rule.withProjectElmJsonVisitor`](./Review-Rule#withProjectElmJsonVisitor).
|
||||||
-}
|
-}
|
||||||
withElmJson : ElmJson -> Project -> Project
|
withElmJson : ElmJson -> Project -> Project
|
||||||
withElmJson elmJson_ (Project project) =
|
withElmJson elmJson_ (Project project) =
|
||||||
|
@ -4,7 +4,7 @@ module Review.Rule exposing
|
|||||||
, newModuleRuleSchema, fromModuleRuleSchema
|
, newModuleRuleSchema, fromModuleRuleSchema
|
||||||
, withSimpleModuleDefinitionVisitor, withSimpleCommentsVisitor, withSimpleImportVisitor, withSimpleDeclarationVisitor, withSimpleExpressionVisitor
|
, withSimpleModuleDefinitionVisitor, withSimpleCommentsVisitor, withSimpleImportVisitor, withSimpleDeclarationVisitor, withSimpleExpressionVisitor
|
||||||
, withModuleDefinitionVisitor, withCommentsVisitor, withImportVisitor, Direction(..), withDeclarationVisitor, withDeclarationListVisitor, withExpressionVisitor, withFinalModuleEvaluation
|
, withModuleDefinitionVisitor, withCommentsVisitor, withImportVisitor, Direction(..), withDeclarationVisitor, withDeclarationListVisitor, withExpressionVisitor, withFinalModuleEvaluation
|
||||||
, withElmJsonVisitor, withDependenciesVisitor
|
, withModuleElmJsonVisitor, withDependenciesVisitor
|
||||||
, withFixes
|
, withFixes
|
||||||
, Error, error, parsingError, errorRuleName, errorMessage, errorDetails, errorRange, errorFixes, errorFilePath
|
, Error, error, parsingError, errorRuleName, errorMessage, errorDetails, errorRange, errorFixes, errorFilePath
|
||||||
, newProjectRuleSchema, fromProjectRuleSchema, traversingImportedModulesFirst, withProjectElmJsonVisitor, withProjectDependenciesVisitor, withFinalProjectEvaluation
|
, newProjectRuleSchema, fromProjectRuleSchema, traversingImportedModulesFirst, withProjectElmJsonVisitor, withProjectDependenciesVisitor, withFinalProjectEvaluation
|
||||||
@ -23,7 +23,7 @@ Then, for each module and rule, it will give the details of your project (like t
|
|||||||
contents of the file to analyze to the rule. The order in which things get passed to the rule is the following:
|
contents of the file to analyze to the rule. The order in which things get passed to the rule is the following:
|
||||||
|
|
||||||
- Read project-related info (only collect data in these steps)
|
- Read project-related info (only collect data in these steps)
|
||||||
- The `elm.json` file, visited by [`withElmJsonVisitor`](#withElmJsonVisitor)
|
- The `elm.json` file, visited by [`withModuleElmJsonVisitor`](#withModuleElmJsonVisitor)
|
||||||
- The definition for dependencies, visited by [`withDependenciesVisitor`](#withDependenciesVisitor)
|
- The definition for dependencies, visited by [`withDependenciesVisitor`](#withDependenciesVisitor)
|
||||||
- Visit the file (in the following order)
|
- Visit the file (in the following order)
|
||||||
- The module definition, visited by [`withSimpleModuleDefinitionVisitor`](#withSimpleModuleDefinitionVisitor) and [`withModuleDefinitionVisitor`](#withModuleDefinitionVisitor)
|
- The module definition, visited by [`withSimpleModuleDefinitionVisitor`](#withSimpleModuleDefinitionVisitor) and [`withModuleDefinitionVisitor`](#withModuleDefinitionVisitor)
|
||||||
@ -175,7 +175,7 @@ patterns you would want to forbid, but that are not handled by the example.
|
|||||||
|
|
||||||
## Builder functions to analyze the project's data
|
## Builder functions to analyze the project's data
|
||||||
|
|
||||||
@docs withElmJsonVisitor, withDependenciesVisitor
|
@docs withModuleElmJsonVisitor, withDependenciesVisitor
|
||||||
|
|
||||||
|
|
||||||
## Automatic fixing
|
## Automatic fixing
|
||||||
@ -194,7 +194,6 @@ For more information on automatic fixing, read the documentation for [`Review.Fi
|
|||||||
|
|
||||||
@docs newProjectRuleSchema, fromProjectRuleSchema, traversingImportedModulesFirst, withProjectElmJsonVisitor, withProjectDependenciesVisitor, withFinalProjectEvaluation
|
@docs newProjectRuleSchema, fromProjectRuleSchema, traversingImportedModulesFirst, withProjectElmJsonVisitor, withProjectDependenciesVisitor, withFinalProjectEvaluation
|
||||||
@docs FileKey, errorForFile
|
@docs FileKey, errorForFile
|
||||||
@docs ReviewResult
|
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
@ -216,9 +215,9 @@ import Review.Project exposing (Project, ProjectModule)
|
|||||||
import Set exposing (Set)
|
import Set exposing (Set)
|
||||||
|
|
||||||
|
|
||||||
{-| Represents a construct able to analyze a module and report unwanted patterns.
|
{-| Represents a construct able to analyze modules from a project and report
|
||||||
See [`newModuleRuleSchema`](#newModuleRuleSchema), and [`fromModuleRuleSchema`](#fromModuleRuleSchema) for how to create one.
|
unwanted patterns.
|
||||||
TODO Explain about single and multi-file rules
|
See [`newModuleRuleSchema`](#newModuleRuleSchema), and [`newProjectRuleSchema`](#newProjectRuleSchema) for how to create one.
|
||||||
-}
|
-}
|
||||||
type Rule
|
type Rule
|
||||||
= ModuleRule String (Project -> ( List Error, Rule ))
|
= ModuleRule String (Project -> ( List Error, Rule ))
|
||||||
@ -364,7 +363,7 @@ take a look at [`withInitialContext`](#withInitialContext) and "with\*" function
|
|||||||
newModuleRuleSchema :
|
newModuleRuleSchema :
|
||||||
String
|
String
|
||||||
-> context
|
-> context
|
||||||
-> ModuleRuleSchema { withElmJsonVisitor : (), withDependenciesVisitor : () } context
|
-> ModuleRuleSchema { withModuleElmJsonVisitor : (), withDependenciesVisitor : () } context
|
||||||
newModuleRuleSchema name_ context =
|
newModuleRuleSchema name_ context =
|
||||||
emptySchema name_ context
|
emptySchema name_ context
|
||||||
|
|
||||||
@ -1268,7 +1267,7 @@ The following example forbids exposing a file in an "Internal" directory in your
|
|||||||
rule : Rule
|
rule : Rule
|
||||||
rule =
|
rule =
|
||||||
Rule.newModuleRuleSchema "DoNoExposeInternalModules" Nothing
|
Rule.newModuleRuleSchema "DoNoExposeInternalModules" Nothing
|
||||||
|> Rule.withElmJsonVisitor elmJsonVisitor
|
|> Rule.withModuleElmJsonVisitor elmJsonVisitor
|
||||||
|> Rule.withModuleDefinitionVisitor moduleDefinitionVisitor
|
|> Rule.withModuleDefinitionVisitor moduleDefinitionVisitor
|
||||||
|> Rule.fromModuleRuleSchema
|
|> Rule.fromModuleRuleSchema
|
||||||
|
|
||||||
@ -1312,11 +1311,11 @@ The following example forbids exposing a file in an "Internal" directory in your
|
|||||||
( [], context )
|
( [], context )
|
||||||
|
|
||||||
-}
|
-}
|
||||||
withElmJsonVisitor :
|
withModuleElmJsonVisitor :
|
||||||
(Maybe Elm.Project.Project -> context -> context)
|
(Maybe Elm.Project.Project -> context -> context)
|
||||||
-> ModuleRuleSchema { anything | withElmJsonVisitor : () } context
|
-> ModuleRuleSchema { anything | withModuleElmJsonVisitor : () } context
|
||||||
-> ModuleRuleSchema { anything | withElmJsonVisitor : () } context
|
-> ModuleRuleSchema { anything | withModuleElmJsonVisitor : () } context
|
||||||
withElmJsonVisitor visitor (ModuleRuleSchema schema) =
|
withModuleElmJsonVisitor visitor (ModuleRuleSchema schema) =
|
||||||
ModuleRuleSchema { schema | elmJsonVisitors = visitor :: schema.elmJsonVisitors }
|
ModuleRuleSchema { schema | elmJsonVisitors = visitor :: schema.elmJsonVisitors }
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ all =
|
|||||||
rule : Rule
|
rule : Rule
|
||||||
rule =
|
rule =
|
||||||
Rule.newModuleRuleSchema "TestRule" "\n0 - withInitialContext"
|
Rule.newModuleRuleSchema "TestRule" "\n0 - withInitialContext"
|
||||||
|> Rule.withElmJsonVisitor (\_ context -> context ++ "\n1 - withElmJsonVisitor")
|
|> Rule.withModuleElmJsonVisitor (\_ context -> context ++ "\n1 - withModuleElmJsonVisitor")
|
||||||
|> Rule.withDependenciesVisitor (\_ context -> context ++ "\n2 - withDependenciesVisitor")
|
|> Rule.withDependenciesVisitor (\_ context -> context ++ "\n2 - withDependenciesVisitor")
|
||||||
|> Rule.withModuleDefinitionVisitor (\_ context -> ( [], context ++ "\n3 - withModuleDefinitionVisitor" ))
|
|> Rule.withModuleDefinitionVisitor (\_ context -> ( [], context ++ "\n3 - withModuleDefinitionVisitor" ))
|
||||||
|> Rule.withImportVisitor (\_ context -> ( [], context ++ "\n4 - withImportVisitor" ))
|
|> Rule.withImportVisitor (\_ context -> ( [], context ++ "\n4 - withImportVisitor" ))
|
||||||
@ -70,7 +70,7 @@ a = 1
|
|||||||
[ Review.Test.error
|
[ Review.Test.error
|
||||||
{ message = """
|
{ message = """
|
||||||
0 - withInitialContext
|
0 - withInitialContext
|
||||||
1 - withElmJsonVisitor
|
1 - withModuleElmJsonVisitor
|
||||||
2 - withDependenciesVisitor
|
2 - withDependenciesVisitor
|
||||||
3 - withModuleDefinitionVisitor
|
3 - withModuleDefinitionVisitor
|
||||||
4 - withImportVisitor
|
4 - withImportVisitor
|
||||||
|
@ -34,7 +34,7 @@ baseRule :
|
|||||||
Rule.ModuleRuleSchema
|
Rule.ModuleRuleSchema
|
||||||
{ hasAtLeastOneVisitor : ()
|
{ hasAtLeastOneVisitor : ()
|
||||||
, withDependenciesVisitor : ()
|
, withDependenciesVisitor : ()
|
||||||
, withElmJsonVisitor : ()
|
, withModuleElmJsonVisitor : ()
|
||||||
}
|
}
|
||||||
Context
|
Context
|
||||||
baseRule =
|
baseRule =
|
||||||
|
Loading…
Reference in New Issue
Block a user