NoFunctionInLet

rule : Rule

Reports functions declared in let expressions.

config =
    [ NoFunctionInLet.rule
    ]

Fail

foo : Int -> Int
foo x =
    let
        somethingIShouldDefineOnTopLevel : Int -> Int
        somethingIShouldDefineOnTopLevel y =
            y + 1
    in
    somethingIShouldDefineOnTopLevel x

Success

somethingIShouldDefineOnTopLevel : Int -> Int
somethingIShouldDefineOnTopLevel y =
    y + 1

foo : Int -> Int
foo x =
    somethingIShouldDefineOnTopLevel x

When (not) to enable this rule

Just don't enable this - whilst it's a good basic rule of thumb, there often needs to be much more to this review than this simple rule can account for.

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 NoFunctionInLet