jfmengels / elm-review-unused / NoUnused.Variables

Report variables or types that are declared or imported but never used inside of a module.

rule : Review.Rule.Rule

Report variables or types that are declared or imported but never used.

🔧 Running with --fix will automatically remove all the reported errors.

config =
    [ NoUnused.Variables.rule
    ]

Fail

module A exposing (a, b)

import UnusedImport

a n =
    n + 1

b =
    let
        unused =
            some thing

        _ =
            someOther thing
    in
    2

c =
    a 2

Success

module A exposing (a, b)

a n =
    n + 1

b =
    2

Exception

To avoid resorting to weird workarounds that are sometimes used in internal interactive examples, the rule won't report values assigned to _ if a direct call to Debug.log is assigned to it.

a value =
    let
        _ =
            Debug.log "value" value
    in
    value + 1

If you enable the NoDebug.Log rule from the jfmengels/elm-review-debug package, and configure it to ignore the locations where it's acceptable, then the combination of both rules will make sure to clean up code like the above in all the other locations.

Try it out

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

elm-review --template jfmengels/elm-review-unused/example --rules NoUnused.Variables