Register exposes values only if they are exposed

This commit is contained in:
Jeroen Engels 2020-01-13 11:03:52 +01:00
parent 1141098f32
commit 6ca138db11
2 changed files with 34 additions and 14 deletions

View File

@ -457,14 +457,18 @@ registerExposed declaration innerContext =
|> .name
|> Node.value
in
{ innerContext
| exposedValues =
{ name = name
, comment = ""
, tipe = convertTypeSignatureToDocsType function.signature
}
:: innerContext.exposedValues
}
if innerContext.exposesEverything || Dict.member name innerContext.exposedNames then
{ innerContext
| exposedValues =
{ name = name
, comment = ""
, tipe = convertTypeSignatureToDocsType function.signature
}
:: innerContext.exposedValues
}
else
innerContext
Declaration.CustomTypeDeclaration type_ ->
innerContext

View File

@ -66,13 +66,16 @@ Http.get -> Http.get
\() ->
[ """module A exposing (..)
import Bar as Baz exposing (baz)
import Foo exposing (..)
import ExposesSomeThings exposing (..)
import ExposesEverything exposing (..)
import Foo.Bar
import Html exposing (..)
import Http exposing (get)
a = b
somethingFromFoo
exposedElement
nonExposedElement
elementFromExposesEverything
Foo.bar
Foo.Bar
Baz.foo
@ -82,8 +85,11 @@ a = b
get
always
Just
""", """module Foo exposing (somethingFromFoo)
somethingFromFoo = 1
""", """module ExposesSomeThings exposing (exposedElement)
exposedElement = 1
nonExposedElement = 2
""", """module ExposesEverything exposing (..)
elementFromExposesEverything = 1
""" ]
|> Review.Test.runOnModulesWithProjectData project rule
|> Review.Test.expectErrorsForModules
@ -91,7 +97,9 @@ somethingFromFoo = 1
, [ Review.Test.error
{ message = """
<nothing>.b -> <nothing>.b
<nothing>.somethingFromFoo -> Foo.somethingFromFoo
<nothing>.exposedElement -> ExposesSomeThings.exposedElement
<nothing>.nonExposedElement -> <nothing>.nonExposedElement
<nothing>.elementFromExposesEverything -> ExposesEverything.elementFromExposesEverything
Foo.bar -> Foo.bar
Foo.Bar -> Foo.Bar
Baz.foo -> Bar.foo
@ -106,7 +114,15 @@ Http.get -> Http.get
}
]
)
, ( "Foo"
, ( "ExposesSomeThings"
, [ Review.Test.error
{ message = ""
, details = [ "details" ]
, under = "module"
}
]
)
, ( "ExposesEverything"
, [ Review.Test.error
{ message = ""
, details = [ "details" ]