Is there a way to determine unused imports in a module?

I know the Elm compiler does dead code elimination. But I still don’t like it when I’ve imported something and it isn’t being used.

import Html exposing (span)

Maybe I was using span but at some point I decided not to use it anymore. If I forget to remove the import I want Elm to tell me that I have an unused import (namely, span). Is there a way to make that happen?

elm-analyse solves the problem quite well. It available as part of the elmLS extension for the vs-code editor :sunny:

3 Likes

elm-analyse catches unused imports. It work really nicely with the elm-language-server, which you can easily hook up to Vim, VSCode etc.

4 Likes

Intellij idea with elm plugin does it pretty well.