🔧NoRecordAliasWithConstructor forbids directly aliasing a record type.
As a consequence, its constructor function becomes unavailable.
Read more about the why in no-record-type-alias-constructor-function.
You can use RecordWithoutConstructorFunction
when directly aliasing a record type to avoid its constructor function becoming unavailable.
type alias User =
{ name : String, age : Int }will be marked as error and automatically fixed:
import Util exposing (WithoutConstructorFunction)
type alias User =
WithoutConstructorFunction
{ name : String, age : Int }import NoRecordAliasWithConstructor exposing (importRecordWithoutConstructorFunctionTypeAlias)
config : List Rule
config =
[ NoRecordAliasWithConstructor.ruleWith
(NoRecordAliasWithConstructor.configDefault
|> importRecordWithoutConstructorFunctionTypeAlias
{ moduleName = "Util"
, typeAliasName = "WithoutConstructorFunction"
}
)
]Configuration where you can specify
RecordWithoutConstructorFunction is: importRecordWithoutConstructorFunctionTypeAliasThe standard Config used for rules without further configuration:
rule =
NoRecordAliasWithConstructor.ruleWith
NoRecordAliasWithConstructor.configDefaultimports RecordWithoutConstructorFunction from lue-bird/elm-no-record-type-alias-constructor-function:
importRecordWithoutConstructorFunctionTypeAlias
{ moduleName = "RecordWithoutConstructorFunction"
, typeAliasName = "RecordWithoutConstructorFunction"
}Configure what
module Your.Module exposing (YourRecordWithoutConstructorFunction)
type alias YourRecordWithoutConstructorFunction record =
recordto import:
import NoRecordAliasWithConstructor exposing (importRecordWithoutConstructorFunctionTypeAlias)
NoRecordAliasWithConstructor.configDefault
|> importRecordWithoutConstructorFunctionTypeAlias
{ moduleName = "Your.Module"
, typeAliasName = "YourRecordWithoutConstructorFunction"
}configDefault imports
RecordWithoutConstructorFunction from lue-bird/elm-no-record-type-alias-constructor-function:
importRecordWithoutConstructorFunctionTypeAlias
{ moduleName = "RecordWithoutConstructorFunction"
, typeAliasName = "RecordWithoutConstructorFunction"
}
🔧
NoRecordAliasWithConstructorforbids directly aliasing a record type. As a consequence, its constructor function becomes unavailable.Read more about the why in
no-record-type-alias-constructor-function.Use
RecordWithoutConstructorFunctionwhen directly aliasing a record type to avoid its constructor function becoming unavailable.example
will be marked as error and automatically fixed:
configuration
Defaults can be altered by using
ruleWithConfig.