mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-28 09:02:53 +03:00
Add NoExposingEverything rule
This commit is contained in:
parent
af030b9e7b
commit
9ebb4ac7d4
7
Lint.elm
7
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 [] []
|
||||
|
||||
_ ->
|
||||
[]
|
||||
|
||||
|
@ -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)
|
||||
|
32
rules/NoExposingEverything.elm
Normal file
32
rules/NoExposingEverything.elm
Normal 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 )
|
Loading…
Reference in New Issue
Block a user