elm-review rule: forbid record type alias constructors.
Read more about the why in no-record-type-alias-constructor-function.
NoRecordAliasConstructor: detect & fix constructor usagesNoRecordAliasWithConstructor: detect record aliases that have a constructor & fix by using RecordWithoutConstructorFunctionNoRecordAliasConstructorIn contrast to lxierita's no-typealias-constructor-call, this rule also reports constructors that aren't called (for example in Json.Decode.mapN functions). ↑ all differences
type alias User =
{ name : String, age : Int }User "Balsa" 42will be marked as error and automatically fixed:
{ name = "Balsa", age = 42 }The same goes for cases where no arguments are applied:
map2 User
(field "name" string)
(field "age" int)fixed
map2 (\name age -> { name = name, age = age })
(field "name" string)
(field "age" int)lxierita/no-typealias-constructor-call...
(User <| "Ann") <| 18
(identity User) "Bill" 42
User |> (\user -> user "Cem" 66)aren't reported for exampleNoRecordAliasWithConstructortype alias User =
{ name : String, age : Int }will be marked as error and automatically fixed:
import RecordWithoutConstructorFunction exposing (RecordWithoutConstructorFunction)
type alias User =
RecordWithoutConstructorFunction
{ name : String, age : Int }disallowing constructor functions from being created.
elm-review --template lue-bird/elm-record-alias-constructor/exampleAfter adding elm-review to your project, import this rule from
your ReviewConfig.elm file and add it to the config. E.g.:
import NoRecordAliasConstructor
import NoRecordAliasWithConstructor
import Review.Rule exposing (Rule)
config : List Rule
config =
[ NoRecordAliasConstructor.rule
, NoRecordAliasWithConstructor.rule
]