Reports records containing only a single field.
config = [ NoSingleFieldRecord.rule ]
type alias SingleFieldRecord = { foo : String } singleFieldRecord : String -> { foo : String } singleFieldRecord foo = { foo = foo } foo : { r | foo : String } -> String foo r = r.foo
type alias MultipleFieldRecord = { foo : String , bar : Int }
Using a record is obsolete if you only plan to store a single field in it. However, there are times when a single field may be desirable, for example:
{ r | some : String }
You can try this rule out by running the following command:
elm-review --template sparksp/elm-review-rules-to-avoid/preview --rules NoSingleFieldRecord
Reports records containing only a single field.
config = [ NoSingleFieldRecord.rule ]
Fail
type alias SingleFieldRecord = { foo : String } singleFieldRecord : String -> { foo : String } singleFieldRecord foo = { foo = foo } foo : { r | foo : String } -> String foo r = r.foo
Success
type alias MultipleFieldRecord = { foo : String , bar : Int }
When (not) to enable this rule
Using a record is obsolete if you only plan to store a single field in it. However, there are times when a single field may be desirable, for example:
{ r | some : String }
. Although, these should be refactored to take one field.Try it out
You can try this rule out by running the following command: