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 |> .name
|> Node.value |> Node.value
in in
{ innerContext if innerContext.exposesEverything || Dict.member name innerContext.exposedNames then
| exposedValues = { innerContext
{ name = name | exposedValues =
, comment = "" { name = name
, tipe = convertTypeSignatureToDocsType function.signature , comment = ""
} , tipe = convertTypeSignatureToDocsType function.signature
:: innerContext.exposedValues }
} :: innerContext.exposedValues
}
else
innerContext
Declaration.CustomTypeDeclaration type_ -> Declaration.CustomTypeDeclaration type_ ->
innerContext innerContext

View File

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