Make NoExposingEverything handle module with a dotted name

This commit is contained in:
Jeroen Engels 2017-06-18 14:33:04 +02:00
parent 60b7ee4710
commit 0503e66803
2 changed files with 19 additions and 14 deletions

View File

@ -47,24 +47,21 @@ createError name =
LintError "NoExposingEverything" ("Do not expose everything from module " ++ name ++ " using (..)")
reportModule : List String -> LintError
reportModule name =
name
|> String.join "."
|> createError
statementFn : Context -> Direction Statement -> ( List LintError, Context )
statementFn ctx node =
case node of
Enter (ModuleDeclaration names AllExport) ->
case names of
[ name ] ->
( [ createError name ], ctx )
Enter (ModuleDeclaration name AllExport) ->
( [ reportModule name ], ctx )
_ ->
( [], ctx )
Enter (PortModuleDeclaration names AllExport) ->
case names of
[ name ] ->
( [ createError name ], ctx )
_ ->
( [], ctx )
Enter (PortModuleDeclaration name AllExport) ->
( [ reportModule name ], ctx )
_ ->
( [], ctx )

View File

@ -52,6 +52,14 @@ tests =
\() ->
testRule "port module Foo exposing (..)"
|> expectErrors [ error "Do not expose everything from module Foo using (..)" ]
, test "should report modules with dotted names that expose everything" <|
\() ->
testRule "module Foo.Bar.Baz exposing (..)"
|> expectErrors [ error "Do not expose everything from module Foo.Bar.Baz using (..)" ]
, test "should report port modules with dotted names that expose everything" <|
\() ->
testRule "port module Foo.Bar.Baz exposing (..)"
|> expectErrors [ error "Do not expose everything from module Foo.Bar.Baz using (..)" ]
]