Make NoExposingEverything handle port module declarations

This commit is contained in:
Jeroen Engels 2017-06-18 14:16:41 +02:00
parent f663aad6fc
commit 6ee43b9d84
4 changed files with 70 additions and 2 deletions

View File

@ -58,5 +58,13 @@ statementFn ctx node =
_ ->
( [], ctx )
Enter (PortModuleDeclaration names AllExport) ->
case names of
[ name ] ->
( [ createError name ], ctx )
_ ->
( [], ctx )
_ ->
( [], ctx )

View File

@ -102,4 +102,4 @@ tests =
all : Test
all =
describe "NoDuplicatedImports" tests
describe "NoDuplicateImports" tests

View File

@ -0,0 +1,60 @@
module NoExposingEverythingTest exposing (all)
import Test exposing (describe, test, Test)
import Lint.Rules.NoExposingEverything exposing (rule)
import Lint.Types exposing (LintRule, LintError, LintResult)
import TestUtil exposing (ruleTester, expectErrors)
testRule : String -> LintResult
testRule =
ruleTester rule
error : String -> LintError
error =
LintError "NoExposingEverything"
tests : List Test
tests =
[ test "should not report modules that do not have a module declaration" <|
\() ->
testRule "bar = 2"
|> expectErrors []
, test "should not report import statements that expose everything" <|
\() ->
testRule """module Foo exposing (foo)
import Html exposing (..)
"""
|> expectErrors []
, test "should not report modules that expose discrete items (single item)" <|
\() ->
testRule "module Foo exposing (foo)"
|> expectErrors []
, test "should not report modules that expose discrete items (multiple items)" <|
\() ->
testRule "module Foo exposing (foo, bar)"
|> expectErrors []
, test "should not report port modules that expose discrete items (single item)" <|
\() ->
testRule "port module Foo exposing (foo)"
|> expectErrors []
, test "should not report port modules that expose discrete items (multiple items)" <|
\() ->
testRule "port module Foo exposing (foo, bar)"
|> expectErrors []
, test "should report modules that expose everything" <|
\() ->
testRule "module Foo exposing (..)"
|> expectErrors [ error "Do not expose everything from module Foo using (..)" ]
, test "should report port modules that expose everything" <|
\() ->
testRule "port module Foo exposing (..)"
|> expectErrors [ error "Do not expose everything from module Foo using (..)" ]
]
all : Test
all =
describe "NoExposingEverything" tests

View File

@ -65,4 +65,4 @@ tests =
all : Test
all =
describe "NoDuplicatedImports" tests
describe "NoImportingEverything" tests