Skip to content

Commit

Permalink
Merge pull request #9 from jxxcarlson/function-body
Browse files Browse the repository at this point in the history
Add module Install.FunctionBody
  • Loading branch information
jxxcarlson authored Jun 3, 2024
2 parents a171f8d + ab9efb0 commit 7bc9508
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/Install/FunctionBody.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module Install.FunctionBody exposing (..)

import Elm.Syntax.Declaration exposing (Declaration(..))
import Elm.Syntax.Expression exposing (Case, Expression(..), Function, FunctionImplementation)
import Elm.Syntax.ModuleName exposing (ModuleName)
import Elm.Syntax.Node as Node exposing (Node(..))
import Elm.Syntax.Pattern exposing (Pattern(..))
import Elm.Syntax.Range exposing (Range)
import List.Extra
import Review.Fix as Fix exposing (Fix)
import Review.Rule as Rule exposing (Error, Rule)
import Set exposing (Set)
import String.Extra


{-| Configuration for makeRule: add a clause to a case expression in a specified function in a specified module.
-}
type Config
= Config
{ moduleName : String
, functionName : String
, functionArgs : List String
, functionBody : String
, customErrorMessage : CustomError
}


{-| Custom error message to be displayed when running `elm-review --fix` or `elm-review --fix-all`
-}
type CustomError
= CustomError { message : String, details : List String }


init : String -> String -> List String -> String -> Config
init moduleName functionName functionArgs functionBody =
Config
{ moduleName = moduleName
, functionName = functionName
, functionArgs = functionArgs
, functionBody = functionBody
, customErrorMessage = CustomError { message = "Replace function body for function " ++ clause, details = [ "" ] }
}

0 comments on commit 7bc9508

Please sign in to comment.