From c09c46e4ebfb939c444d46f1855f619d3ebfa1e2 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Mon, 2 Mar 2020 22:52:22 +0100 Subject: [PATCH] Rename withProjectElmJsonVisitor to withElmJsonProjectVisitor --- src/NoInvalidLicense.elm | 2 +- src/NoUnusedDependencies.elm | 2 +- src/NoUnusedExports.elm | 2 +- src/NoUnusedModules.elm | 2 +- src/Review/Project.elm | 2 +- src/Review/Rule.elm | 20 ++++++++++---------- tests/Review/RuleElmJsonErrorsTest.elm | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/NoInvalidLicense.elm b/src/NoInvalidLicense.elm index c6e17606..9b07960a 100644 --- a/src/NoInvalidLicense.elm +++ b/src/NoInvalidLicense.elm @@ -40,7 +40,7 @@ rule configuration = , fromModuleToProject = fromModuleToProject , foldProjectContexts = foldProjectContexts } - |> Rule.withProjectElmJsonVisitor elmJsonVisitor + |> Rule.withElmJsonProjectVisitor elmJsonVisitor |> Rule.withProjectDependenciesVisitor dependenciesVisitor |> Rule.withFinalProjectEvaluation (finalEvaluationForProject configuration) |> Rule.fromProjectRuleSchema diff --git a/src/NoUnusedDependencies.elm b/src/NoUnusedDependencies.elm index e2f9b987..a05c36b3 100644 --- a/src/NoUnusedDependencies.elm +++ b/src/NoUnusedDependencies.elm @@ -53,7 +53,7 @@ rule = , fromModuleToProject = fromModuleToProject , foldProjectContexts = foldProjectContexts } - |> Rule.withProjectElmJsonVisitor elmJsonVisitor + |> Rule.withElmJsonProjectVisitor elmJsonVisitor |> Rule.withProjectDependenciesVisitor dependenciesVisitor |> Rule.withFinalProjectEvaluation finalEvaluationForProject |> Rule.fromProjectRuleSchema diff --git a/src/NoUnusedExports.elm b/src/NoUnusedExports.elm index 14494719..3beec3db 100644 --- a/src/NoUnusedExports.elm +++ b/src/NoUnusedExports.elm @@ -62,7 +62,7 @@ rule = } |> Scope.addProjectVisitors |> Rule.withContextFromImportedModules - |> Rule.withProjectElmJsonVisitor elmJsonVisitor + |> Rule.withElmJsonProjectVisitor elmJsonVisitor |> Rule.withFinalProjectEvaluation finalEvaluationForProject |> Rule.fromProjectRuleSchema diff --git a/src/NoUnusedModules.elm b/src/NoUnusedModules.elm index 083bb1b9..c4a38d2d 100644 --- a/src/NoUnusedModules.elm +++ b/src/NoUnusedModules.elm @@ -53,7 +53,7 @@ rule = , fromModuleToProject = fromModuleToProject , foldProjectContexts = foldProjectContexts } - |> Rule.withProjectElmJsonVisitor elmJsonVisitor + |> Rule.withElmJsonProjectVisitor elmJsonVisitor |> Rule.withFinalProjectEvaluation finalEvaluationForProject |> Rule.fromProjectRuleSchema diff --git a/src/Review/Project.elm b/src/Review/Project.elm index 239b496f..19ddb1cd 100644 --- a/src/Review/Project.elm +++ b/src/Review/Project.elm @@ -275,7 +275,7 @@ precomputeModuleGraph ((Project p) as project) = {-| Add the content of the `elm.json` file to the project details, making it available for rules to access using [`Review.Rule.withElmJsonModuleVisitor`](./Review-Rule#withElmJsonModuleVisitor) and -[`Review.Rule.withProjectElmJsonVisitor`](./Review-Rule#withProjectElmJsonVisitor). +[`Review.Rule.withElmJsonProjectVisitor`](./Review-Rule#withElmJsonProjectVisitor). The `raw` value should be the raw JSON as a string, and `contents` corresponds to [`elm/project-metadata-utils`'s Project project structure](https://package.elm-lang.org/packages/elm/project-metadata-utils/latest/Elm-Project). diff --git a/src/Review/Rule.elm b/src/Review/Rule.elm index 0c7673b0..4389dde5 100644 --- a/src/Review/Rule.elm +++ b/src/Review/Rule.elm @@ -5,7 +5,7 @@ module Review.Rule exposing , withSimpleModuleDefinitionVisitor, withSimpleCommentsVisitor, withSimpleImportVisitor, withSimpleDeclarationVisitor, withSimpleExpressionVisitor , withModuleDefinitionVisitor, withCommentsVisitor, withImportVisitor, Direction(..), withDeclarationVisitor, withDeclarationListVisitor, withExpressionVisitor, withFinalModuleEvaluation , withElmJsonModuleVisitor, withModuleDependenciesVisitor - , ProjectRuleSchema, newProjectRuleSchema, fromProjectRuleSchema, withProjectElmJsonVisitor, withProjectDependenciesVisitor, withFinalProjectEvaluation, withContextFromImportedModules + , ProjectRuleSchema, newProjectRuleSchema, fromProjectRuleSchema, withElmJsonProjectVisitor, withProjectDependenciesVisitor, withFinalProjectEvaluation, withContextFromImportedModules , Error, error, errorRuleName, errorMessage, errorDetails, errorRange, errorFixes, errorFilePath, ModuleKey, errorForFile, ElmJsonKey, errorForElmJson , withFixes , ignoreErrorsForDirectories, ignoreErrorsForFiles @@ -189,7 +189,7 @@ Evaluating/visiting a node means two things: ## Creating a project rule -@docs ProjectRuleSchema, newProjectRuleSchema, fromProjectRuleSchema, withProjectElmJsonVisitor, withProjectDependenciesVisitor, withFinalProjectEvaluation, withContextFromImportedModules +@docs ProjectRuleSchema, newProjectRuleSchema, fromProjectRuleSchema, withElmJsonProjectVisitor, withProjectDependenciesVisitor, withFinalProjectEvaluation, withContextFromImportedModules ## Errors @@ -750,7 +750,7 @@ Let's go through an example of a rule that reports unused modules. , fromModuleToProject = fromModuleToProject , foldProjectContexts = foldProjectContexts } - |> Rule.withProjectElmJsonVisitor elmJsonVisitor + |> Rule.withElmJsonProjectVisitor elmJsonVisitor |> Rule.withFinalProjectEvaluation finalProjectEvaluation |> Rule.fromProjectRuleSchema @@ -762,7 +762,7 @@ Let's go through an example of a rule that reports unused modules. The rule will work like this: - - We will visit the `elm.json` ([`withProjectElmJsonVisitor`](#withProjectElmJsonVisitor)) to determine whether this project is a package + - We will visit the `elm.json` ([`withElmJsonProjectVisitor`](#withElmJsonProjectVisitor)) to determine whether this project is a package or an application. If it's a package, we will mark the exposed modules as used. - We will visit every module (`moduleVisitor`), and for every one: - If the project is an application, mark the module as used if it contains a `main` function. @@ -775,7 +775,7 @@ You define how you want to visit each file with `moduleVisitor`. `moduleVisitor` same visitors as for module rules. The exception are the following visitors, which are replaced by functions that you need to use on the project rule schema. - - [`withElmJsonModuleVisitor`](#withElmJsonModuleVisitor), replaced by [`withProjectElmJsonVisitor`](#withProjectElmJsonVisitor) + - [`withElmJsonModuleVisitor`](#withElmJsonModuleVisitor), replaced by [`withElmJsonProjectVisitor`](#withElmJsonProjectVisitor) - [`withModuleDependenciesVisitor`](#withModuleDependenciesVisitor), replaced by [`withProjectDependenciesVisitor`](#withProjectDependenciesVisitor) - [`withFinalModuleEvaluation`](#withFinalModuleEvaluation), replaced by [`withFinalProjectEvaluation`](#withFinalProjectEvaluation) @@ -899,7 +899,7 @@ Before looking at modules...TODO - A final evaluation is made when the module has fully been visited, using [`withFinalModuleEvaluation`](#withFinalModuleEvaluation) You can't use [`withElmJsonModuleVisitor`](#withElmJsonModuleVisitor) or [`withModuleDependenciesVisitor`](#withModuleDependenciesVisitor) -in project rules. Instead, you should use [`withProjectElmJsonVisitor`](#withProjectElmJsonVisitor) or [`withProjectDependenciesVisitor`](#withProjectDependenciesVisitor). +in project rules. Instead, you should use [`withElmJsonProjectVisitor`](#withElmJsonProjectVisitor) or [`withProjectDependenciesVisitor`](#withProjectDependenciesVisitor). -} newProjectRuleSchema : @@ -949,11 +949,11 @@ fromProjectRuleSchema (ProjectRuleSchema schema) = {-| TODO documentation -} -withProjectElmJsonVisitor : +withElmJsonProjectVisitor : (Maybe { elmJsonKey : ElmJsonKey, project : Elm.Project.Project } -> projectContext -> projectContext) -> ProjectRuleSchema projectContext moduleContext -> ProjectRuleSchema projectContext moduleContext -withProjectElmJsonVisitor visitor (ProjectRuleSchema schema) = +withElmJsonProjectVisitor visitor (ProjectRuleSchema schema) = ProjectRuleSchema { schema | elmJsonVisitors = visitor :: schema.elmJsonVisitors } @@ -985,7 +985,7 @@ When you finish analyzing a module, the `moduleContext` is turned into a `projec through [`fromModuleToProject`](#newProjectRuleSchema). Before analyzing a file, the `projectContext`s of its imported modules get folded into a single one starting with the initial context (that may have visited the -[`elm.json` file](#withProjectElmJsonVisitor) and/or the [project's dependencies](#withProjectDependenciesVisitor)) +[`elm.json` file](#withElmJsonProjectVisitor) and/or the [project's dependencies](#withProjectDependenciesVisitor)) using [`foldProjectContexts`](#newProjectRuleSchema). If there is information about another module that you wish to access, you should @@ -2179,7 +2179,7 @@ errorForFile (ModuleKey path) { message, details } range = key in order to use the [`errorForElmJson`](#errorForElmJson) function. This is to prevent creating errors for it if you have not visited it. -You can get a `ElmJsonKey` using the [`withProjectElmJsonVisitor`](#withProjectElmJsonVisitor) function. +You can get a `ElmJsonKey` using the [`withElmJsonProjectVisitor`](#withElmJsonProjectVisitor) function. -} type ElmJsonKey diff --git a/tests/Review/RuleElmJsonErrorsTest.elm b/tests/Review/RuleElmJsonErrorsTest.elm index 60627044..9d3982d5 100644 --- a/tests/Review/RuleElmJsonErrorsTest.elm +++ b/tests/Review/RuleElmJsonErrorsTest.elm @@ -22,7 +22,7 @@ rule = , fromModuleToProject = fromModuleToProject , foldProjectContexts = foldProjectContexts } - |> Rule.withProjectElmJsonVisitor (\elmJson _ -> elmJson |> Maybe.map .elmJsonKey) + |> Rule.withElmJsonProjectVisitor (\elmJson _ -> elmJson |> Maybe.map .elmJsonKey) |> Rule.withFinalProjectEvaluation finalEvaluationForProject |> Rule.fromProjectRuleSchema