Skip to content

Commit

Permalink
Don't report types used in port declarations
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
jfmengels committed Apr 30, 2021
1 parent 442fe10 commit 542e9eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/NoUnused/Exports.elm
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ typesUsedInDeclaration moduleContext declaration =
Declaration.AliasDeclaration alias_ ->
( collectTypesFromTypeAnnotation moduleContext alias_.typeAnnotation, False )

Declaration.PortDeclaration _ ->
( [], False )
Declaration.PortDeclaration signature ->
( collectTypesFromTypeAnnotation moduleContext signature.typeAnnotation, False )

Declaration.InfixDeclaration _ ->
( [], False )
Expand Down
22 changes: 22 additions & 0 deletions tests/NoUnused/ExportsTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,28 @@ main =
type1
""", """module B exposing (Type1)
type Type1 = Type1
""" ]
|> Review.Test.runOnModulesWithProjectData application rule
|> Review.Test.expectNoErrors
, test "should not report an exposed type if it is used in a port (input)" <|
\() ->
[ """module Main exposing (main)
import B
main = somePort
port somePort : (B.Type1 -> msg) -> Sub msg
""", """module B exposing (Type1)
type alias Type1 = { user : String }
""" ]
|> Review.Test.runOnModulesWithProjectData application rule
|> Review.Test.expectNoErrors
, test "should not report an exposed type if it is used in a port (output)" <|
\() ->
[ """module Main exposing (main)
import B
main = somePort
port somePort : B.Type1 -> Cmd msg
""", """module B exposing (Type1)
type alias Type1 = { user : String }
""" ]
|> Review.Test.runOnModulesWithProjectData application rule
|> Review.Test.expectNoErrors
Expand Down

0 comments on commit 542e9eb

Please sign in to comment.