mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-23 17:53:35 +03:00
Make NoExposingEverything handle port module declarations
This commit is contained in:
parent
f663aad6fc
commit
6ee43b9d84
@ -58,5 +58,13 @@ statementFn ctx node =
|
||||
_ ->
|
||||
( [], ctx )
|
||||
|
||||
Enter (PortModuleDeclaration names AllExport) ->
|
||||
case names of
|
||||
[ name ] ->
|
||||
( [ createError name ], ctx )
|
||||
|
||||
_ ->
|
||||
( [], ctx )
|
||||
|
||||
_ ->
|
||||
( [], ctx )
|
||||
|
@ -102,4 +102,4 @@ tests =
|
||||
|
||||
all : Test
|
||||
all =
|
||||
describe "NoDuplicatedImports" tests
|
||||
describe "NoDuplicateImports" tests
|
||||
|
60
tests/NoExposingEverythingTest.elm
Normal file
60
tests/NoExposingEverythingTest.elm
Normal 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
|
@ -65,4 +65,4 @@ tests =
|
||||
|
||||
all : Test
|
||||
all =
|
||||
describe "NoDuplicatedImports" tests
|
||||
describe "NoImportingEverything" tests
|
||||
|
Loading…
Reference in New Issue
Block a user