NoNothingToNothing

rule : Rule

Reports case expressions where Nothing is matched and then Nothing is returned.

config =
    [ NoNothingToNothing.rule
    ]

Fail

greet : Maybe String -> Maybe String
greet maybeName =
    case maybeName of
        Nothing ->
            Nothing

        Just name ->
            Just ("Hello " ++ name)

Success

greet : Maybe String -> Maybe String
greet maybeName =
    case maybeName of
        Nothing ->
            Just "Hello"

        Just name ->
            Just ("Hello " ++ name)

When (not) to enable this rule

You don't need this rule. If you're writing code like this then there may be some wider code restructures to consider.

Try it out

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

elm-review --template sparksp/elm-review-rules-to-avoid/preview --rules NoNothingToNothing