diff --git a/Lint.elm b/Lint.elm index 4d35c44b..98c09550 100644 --- a/Lint.elm +++ b/Lint.elm @@ -75,10 +75,10 @@ typeToVisitors node = statementToVisitors : Statement -> List (Visitor context) statementToVisitors node = let - visitAndTransformChildren expresssions types = + visitAndTransformChildren expressions types = List.concat [ [ statementVisitor node ] - , List.concatMap expressionToVisitors expresssions + , List.concatMap expressionToVisitors expressions , List.concatMap typeToVisitors types ] in @@ -89,6 +89,9 @@ statementToVisitors node = FunctionDeclaration name params body -> visitAndTransformChildren [ body ] [] + ModuleDeclaration name exportSet -> + visitAndTransformChildren [] [] + _ -> [] diff --git a/example/Main.elm b/example/Main.elm index 574c8c2b..98e4aa5a 100644 --- a/example/Main.elm +++ b/example/Main.elm @@ -9,8 +9,13 @@ import Html.Attributes exposing (id) import Html.Events exposing (..) import Json.Decode as JD import Lint -import NoDebug + + +-- Rules + import FindNoAnnotatedFunction +import NoDebug +import NoExposingEverything type Msg @@ -107,6 +112,7 @@ lint ast = List.concat [ lint FindNoAnnotatedFunction.rule , lint NoDebug.rule + , lint NoExposingEverything.rule ] in div [] (List.map (\x -> p [] [ text x ]) errors) diff --git a/rules/NoExposingEverything.elm b/rules/NoExposingEverything.elm new file mode 100644 index 00000000..e2e858bf --- /dev/null +++ b/rules/NoExposingEverything.elm @@ -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 )