elm-language-server icon indicating copy to clipboard operation
elm-language-server copied to clipboard

When all import values are unused, we should check if import is unused

Open jmbockhorst opened this issue 3 years ago • 0 comments

For example, in import Foo exposing (foo, bar) if foo and bar are unused, we should check if the module Foo is unused.

How to implement

Would need to run getUnusedImportValueAndTypeDiagnostics first and keep a cache of imports with all unused values, then pass that cache to getUnusedImportDiagnostics, where instead of always skipping if there is an exposing list, we would not skip if all values are unused.

https://github.com/elm-tooling/elm-language-server/blob/f4ce9e901e9e23482e1273e825190de9450d480f/src/providers/diagnostics/elmLsDiagnostics.ts#L520

would become something like

!node.parent?.childForFieldName("exposing") || cache.get(moduleName).allValuesUnused

jmbockhorst avatar Mar 05 '21 17:03 jmbockhorst