rule : Review.Rule.Rule
🔧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
.
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 RecordWithoutConstructorFunction exposing (RecordWithoutConstructorFunction)
type alias User =
RecordWithoutConstructorFunction
{ name : String, age : Int }
import NoRecordAliasWithConstructor
config : List Rule
config =
[ NoRecordAliasWithConstructor.rule
]
Defaults can be altered by using ruleWith
Config
.
ruleWith : Config -> Review.Rule.Rule
🔧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"
}
)
]
rule
simply uses the default Config
.
Configuration where you can specify
RecordWithoutConstructorFunction
is: importRecordWithoutConstructorFunctionTypeAlias
configDefault : Config
The standard Config
used for rule
s without further configuration:
rule =
NoRecordAliasWithConstructor.ruleWith
NoRecordAliasWithConstructor.configDefault
RecordWithoutConstructorFunction
from lue-bird/elm-no-record-type-alias-constructor-function
:importRecordWithoutConstructorFunctionTypeAlias
{ moduleName = "RecordWithoutConstructorFunction"
, typeAliasName = "RecordWithoutConstructorFunction"
}
importRecordWithoutConstructorFunctionTypeAlias : { moduleName : String, typeAliasName : String } -> Config -> Config
Configure what
module Your.Module exposing (YourRecordWithoutConstructorFunction)
type alias YourRecordWithoutConstructorFunction record =
record
to 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"
}