mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-24 18:23:09 +03:00
Rename Project.withDependency and Project.withElmJson to Project.add*
This commit is contained in:
parent
a2037ea973
commit
6f73e42b9a
@ -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 =
|
||||
|
@ -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 =
|
||||
|
@ -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)
|
||||
|
@ -17,7 +17,7 @@ testRule string =
|
||||
projectWithHtmlDependency : Project
|
||||
projectWithHtmlDependency =
|
||||
Project.new
|
||||
|> Project.withDependency Dependencies.elmHtml
|
||||
|> Project.addDependency Dependencies.elmHtml
|
||||
|
||||
|
||||
testRuleWithHtmlDependency : String -> ReviewResult
|
||||
|
@ -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 }
|
||||
|
@ -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 }
|
||||
|
@ -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 }
|
||||
|
@ -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 }
|
||||
|
@ -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 }
|
||||
|
@ -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
|
||||
|
@ -54,7 +54,7 @@ a = 1
|
||||
project : Project
|
||||
project =
|
||||
Project.new
|
||||
|> Project.withElmJson applicationElmJson
|
||||
|> Project.addElmJson applicationElmJson
|
||||
|
||||
|
||||
elmCore : () -> Elm.Package.Name
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user