mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-24 15:54:02 +03:00
40 lines
886 B
Elm
40 lines
886 B
Elm
module NoImportingEverything exposing (rule)
|
|
|
|
import Lint exposing (lint, doNothing)
|
|
import Types exposing (LintRule, Error, Direction(..))
|
|
import Ast.Statement exposing (..)
|
|
|
|
|
|
type alias Context =
|
|
{}
|
|
|
|
|
|
rule : String -> List Error
|
|
rule input =
|
|
lint input implementation
|
|
|
|
|
|
implementation : LintRule Context
|
|
implementation =
|
|
{ statementFn = statementFn
|
|
, typeFn = doNothing
|
|
, expressionFn = doNothing
|
|
, moduleEndFn = (\ctx -> ( [], ctx ))
|
|
, initialContext = Context
|
|
}
|
|
|
|
|
|
error : String -> Error
|
|
error name =
|
|
Error "NoImportingEverything" ("Do not expose everything from " ++ name)
|
|
|
|
|
|
statementFn : Context -> Direction Statement -> ( List Error, Context )
|
|
statementFn ctx node =
|
|
case node of
|
|
Enter (ImportStatement names alias (Just AllExport)) ->
|
|
( [ error <| String.join "." names ], ctx )
|
|
|
|
_ ->
|
|
( [], ctx )
|