This is a simple rule for the elm-review tool that will help flagging cases where Ids are represented as String. It is quite often the case that we see the following pattern in elm code:
type alias Stuff =
{ id: String,
, ...
}However, this leads to many confusing calls on function dealing with both stuffs and things:
function: String -> String -> List String -> List Something -> SomethingElse
function stuffId thingId stuffs things =
...Instead it would be much nicer to have something like this:
type StuffId =
StuffId String
type ThingId =
ThingId String
type alias Stuff =
{ id: StuffId
, ...
}
function: StuffId -> ThingId -> List StuffId -> List Something -> SomethingElse
function stuffId thingId stuffIds things =
...Which makes it much harder to mess-up the arguments' order or to feed SomethingId instead of a StuffId...
String being used for something else that what they are.elm-review.import NoStringAsId
import Review.Rule exposing (Rule)
config : List Rule
config =
[ NoStringAsId.rule
]