mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-25 18:51:41 +03:00
Report unused import aliases
This commit is contained in:
parent
78562d1de5
commit
527ee1c43a
@ -220,10 +220,24 @@ importVisitor node context =
|
||||
)
|
||||
|
||||
Just declaredImports ->
|
||||
let
|
||||
contextWithoutImports : Context
|
||||
contextWithoutImports =
|
||||
case Node.value node |> .moduleAlias of
|
||||
Just moduleAlias ->
|
||||
register
|
||||
ModuleAlias
|
||||
(Node.range moduleAlias)
|
||||
(Node.value moduleAlias |> getModuleName)
|
||||
context
|
||||
|
||||
Nothing ->
|
||||
context
|
||||
in
|
||||
( []
|
||||
, List.foldl
|
||||
(\( variableType, range, name ) context_ -> register variableType range name context_)
|
||||
context
|
||||
contextWithoutImports
|
||||
(collectFromExposing declaredImports)
|
||||
)
|
||||
|
||||
|
@ -344,6 +344,19 @@ import Html.Styled.Attributes as Html"""
|
||||
}
|
||||
|> Lint.Test.atExactly { start = { row = 2, column = 34 }, end = { row = 2, column = 38 } }
|
||||
]
|
||||
, test "should report unused import alias even if it exposes a used type" <|
|
||||
\() ->
|
||||
testRule """module A exposing (a)
|
||||
import Html.Styled.Attributes as Html exposing (Attribute)
|
||||
a : Attribute
|
||||
a = ()"""
|
||||
|> Lint.Test.expectErrors
|
||||
[ Lint.Test.error
|
||||
{ message = "Module alias `Html` is not used"
|
||||
, under = "Html"
|
||||
}
|
||||
|> Lint.Test.atExactly { start = { row = 2, column = 34 }, end = { row = 2, column = 38 } }
|
||||
]
|
||||
, test "should not report import that exposes a used exposed type" <|
|
||||
\() ->
|
||||
testRule """module A exposing (a)
|
||||
|
Loading…
Reference in New Issue
Block a user