jfmengels / elm-review-the-elm-architecture / NoUselessSubscriptions

rule : Review.Rule.Rule

Reports subscriptions functions that never return a subscription.

In my opinion, this is often a sign of premature architectural work, where you set up an init, view, update and subscriptions functions. I think it is better to define them as they are needed, to avoid adding upfront complexity that turn out to be unnecessary later.

config =
    [ NoUselessSubscriptions.rule
    ]

Fail

subscriptions : Model -> Sub Msg
subscriptions model =
    Sub.none

Success

main =
    Browser.element
        { init = init
        , update = update
        , subscriptions = \_ -> Sub.none
        , view = view
        }

Try it out

You can try this rule out by running the following command:

elm-review --template jfmengels/elm-review-the-elm-architecture/example --rules NoUselessSubscriptions