Rename Project.withDependency and Project.withElmJson to Project.add*

This commit is contained in:
Jeroen Engels 2020-03-19 23:50:41 +01:00
parent a2037ea973
commit 6f73e42b9a
13 changed files with 30 additions and 30 deletions

View File

@ -1,9 +1,9 @@
module Review.Project exposing
( Project, new
, ProjectModule, addModule, addParsedModule, removeModule, modules, filesThatFailedToParse, moduleGraph, precomputeModuleGraph
, withElmJson, elmJson
, addElmJson, elmJson
, withReadme, readme
, withDependency, removeDependencies, dependencies
, addDependency, removeDependencies, dependencies
)
{-| Represents the contents of the project to be analyzed. This information will
@ -33,7 +33,7 @@ does not look at project information (like the `elm.json`, dependencies, ...).
# `elm.json`
@docs withElmJson, elmJson
@docs addElmJson, elmJson
# `README.md`
@ -43,7 +43,7 @@ does not look at project information (like the `elm.json`, dependencies, ...).
# Project dependencies
@docs withDependency, removeDependencies, dependencies
@docs addDependency, removeDependencies, dependencies
-}
@ -282,8 +282,8 @@ The `raw` value should be the raw JSON as a string, and `contents` corresponds t
[`elm/project-metadata-utils`'s Project project structure](https://package.elm-lang.org/packages/elm/project-metadata-utils/latest/Elm-Project).
-}
withElmJson : { path : String, raw : String, project : Elm.Project.Project } -> Project -> Project
withElmJson elmJson_ (Project project) =
addElmJson : { path : String, raw : String, project : Elm.Project.Project } -> Project -> Project
addElmJson elmJson_ (Project project) =
Project { project | elmJson = Just elmJson_ }
@ -342,8 +342,8 @@ associativity of operators, which has an impact on the resulting AST when
parsing a file.
-}
withDependency : Dependency -> Project -> Project
withDependency dependency (Project project) =
addDependency : Dependency -> Project -> Project
addDependency dependency (Project project) =
Project
{ project
| dependencies =

View File

@ -64,7 +64,7 @@ You could something like the following to create a test project in your tests.
testProject : Project
testProject =
Project.new
|> Project.withDependency
|> Project.addDependency
dependency : String -> Dependency
dependency license =

View File

@ -211,7 +211,7 @@ project loaded, such as the contents of `elm.json` file.
project : Project
project =
Project.new
|> Project.withElmJson elmJsonToConstructManually
|> Project.addElmJson elmJsonToConstructManually
in
"""module SomeModule exposing (a)
a = 1"""
@ -255,7 +255,7 @@ several files, and where the context of the project is important.
project : Project
project =
Project.new
|> Project.withElmJson elmJsonToConstructManually
|> Project.addElmJson elmJsonToConstructManually
in
[ """
module A exposing (a)

View File

@ -17,7 +17,7 @@ testRule string =
projectWithHtmlDependency : Project
projectWithHtmlDependency =
Project.new
|> Project.withDependency Dependencies.elmHtml
|> Project.addDependency Dependencies.elmHtml
testRuleWithHtmlDependency : String -> ReviewResult

View File

@ -13,8 +13,8 @@ import Test exposing (Test, describe, test)
createProject : String -> Project
createProject license =
Project.new
|> Project.withElmJson (createElmJson applicationElmJson)
|> Project.withDependency (dependency license)
|> Project.addElmJson (createElmJson applicationElmJson)
|> Project.addDependency (dependency license)
createElmJson : String -> { path : String, raw : String, project : Elm.Project.Project }

View File

@ -11,13 +11,13 @@ import Test exposing (Test, describe, test)
packageProject : Project
packageProject =
Project.new
|> Project.withElmJson (createElmJson packageElmJson)
|> Project.addElmJson (createElmJson packageElmJson)
applicationProject : Project
applicationProject =
Project.new
|> Project.withElmJson (createElmJson applicationElmJson)
|> Project.addElmJson (createElmJson applicationElmJson)
createElmJson : String -> { path : String, raw : String, project : Elm.Project.Project }

View File

@ -13,9 +13,9 @@ import Test exposing (Test, describe, test)
createProject : String -> Project
createProject rawElmJson =
Project.new
|> Project.withElmJson (createElmJson rawElmJson)
|> Project.withDependency packageWithFoo
|> Project.withDependency packageWithBar
|> Project.addElmJson (createElmJson rawElmJson)
|> Project.addDependency packageWithFoo
|> Project.addDependency packageWithBar
createElmJson : String -> { path : String, raw : String, project : Elm.Project.Project }

View File

@ -12,7 +12,7 @@ import Test exposing (Test, describe, test)
application : Project
application =
Project.new
|> Project.withElmJson applicationElmJson
|> Project.addElmJson applicationElmJson
applicationElmJson : { path : String, raw : String, project : Elm.Project.Project }
@ -50,7 +50,7 @@ applicationElmJson =
package_ : Project
package_ =
Project.new
|> Project.withElmJson (createPackageElmJson ())
|> Project.addElmJson (createPackageElmJson ())
createPackageElmJson : () -> { path : String, raw : String, project : Elm.Project.Project }

View File

@ -12,7 +12,7 @@ import Test exposing (Test, describe, test)
application : Project
application =
Project.new
|> Project.withElmJson applicationElmJson
|> Project.addElmJson applicationElmJson
applicationElmJson : { path : String, raw : String, project : Elm.Project.Project }
@ -50,7 +50,7 @@ applicationElmJson =
package_ : Project
package_ =
Project.new
|> Project.withElmJson (createPackageElmJson ())
|> Project.addElmJson (createPackageElmJson ())
createPackageElmJson : () -> { path : String, raw : String, project : Elm.Project.Project }

View File

@ -61,7 +61,7 @@ all =
, test "should report an error if the README.md file doesn't start with the project name" <|
\() ->
Project.new
|> Project.withElmJson (createElmJson packageElmJson)
|> Project.addElmJson (createElmJson packageElmJson)
|> Project.withReadme { path = "README.md", content = "Hello everybody\nThis is a good project" }
|> testRule
|> Review.Test.expectErrorsForReadme
@ -74,7 +74,7 @@ all =
, test "should not report an error if the README.md file starts with the project name" <|
\() ->
Project.new
|> Project.withElmJson (createElmJson packageElmJson)
|> Project.addElmJson (createElmJson packageElmJson)
|> Project.withReadme { path = "README.md", content = "# author/packagename\nHello everybody\nThis is a good project" }
|> testRule
|> Review.Test.expectNoErrors

View File

@ -54,7 +54,7 @@ a = 1
project : Project
project =
Project.new
|> Project.withElmJson applicationElmJson
|> Project.addElmJson applicationElmJson
elmCore : () -> Elm.Package.Name

View File

@ -120,8 +120,8 @@ type alias ModuleContext =
project : Project
project =
Project.new
|> Project.withDependency Dependencies.elmCore
|> Project.withDependency Dependencies.elmHtml
|> Project.addDependency Dependencies.elmCore
|> Project.addDependency Dependencies.elmHtml
rule : Rule

View File

@ -19,8 +19,8 @@ type alias Context =
project : Project
project =
Project.new
|> Project.withDependency Dependencies.elmCore
|> Project.withDependency Dependencies.elmHtml
|> Project.addDependency Dependencies.elmCore
|> Project.addDependency Dependencies.elmHtml
testRule : Rule -> String -> ReviewResult