Add NoExposingEverything rule

This commit is contained in:
Jeroen Engels 2017-01-08 11:44:31 +01:00
parent af030b9e7b
commit 9ebb4ac7d4
3 changed files with 44 additions and 3 deletions

View File

@ -75,10 +75,10 @@ typeToVisitors node =
statementToVisitors : Statement -> List (Visitor context) statementToVisitors : Statement -> List (Visitor context)
statementToVisitors node = statementToVisitors node =
let let
visitAndTransformChildren expresssions types = visitAndTransformChildren expressions types =
List.concat List.concat
[ [ statementVisitor node ] [ [ statementVisitor node ]
, List.concatMap expressionToVisitors expresssions , List.concatMap expressionToVisitors expressions
, List.concatMap typeToVisitors types , List.concatMap typeToVisitors types
] ]
in in
@ -89,6 +89,9 @@ statementToVisitors node =
FunctionDeclaration name params body -> FunctionDeclaration name params body ->
visitAndTransformChildren [ body ] [] visitAndTransformChildren [ body ] []
ModuleDeclaration name exportSet ->
visitAndTransformChildren [] []
_ -> _ ->
[] []

View File

@ -9,8 +9,13 @@ import Html.Attributes exposing (id)
import Html.Events exposing (..) import Html.Events exposing (..)
import Json.Decode as JD import Json.Decode as JD
import Lint import Lint
import NoDebug
-- Rules
import FindNoAnnotatedFunction import FindNoAnnotatedFunction
import NoDebug
import NoExposingEverything
type Msg type Msg
@ -107,6 +112,7 @@ lint ast =
List.concat List.concat
[ lint FindNoAnnotatedFunction.rule [ lint FindNoAnnotatedFunction.rule
, lint NoDebug.rule , lint NoDebug.rule
, lint NoExposingEverything.rule
] ]
in in
div [] (List.map (\x -> p [] [ text x ]) errors) div [] (List.map (\x -> p [] [ text x ]) errors)

View File

@ -0,0 +1,32 @@
module NoExposingEverything exposing (rule)
import Lint exposing (LintRule, Error, doNothing)
import Ast.Statement exposing (..)
type alias Context =
{}
rule : LintRule Context
rule =
{ statementFn = statementFn
, typeFn = doNothing
, expressionFn = doNothing
, context = Context
}
statementFn : Context -> Statement -> ( List Error, Context )
statementFn ctx node =
case node of
ModuleDeclaration names AllExport ->
case names of
[ name ] ->
( [ "Do not expose everything from module " ++ name ++ " using (..)" ], ctx )
_ ->
( [], ctx )
_ ->
( [], ctx )