webbhuset / elm-review-forbid-specific-imports / ForbidSpecificImports


type alias Config =
List ( String
, List String 
}

rule : Config -> Review.Rule.Rule

Reports when a module in a namespace imports from a list of other namespaces.

config : List Rule
config =
    [ ForbidSpecificImports.rule
        [ ( "App.Data", [ "App.View" ] )
        ]
    ]

Fail

This fails because we've forbidden modules in App.Data to import from App.View.

module App.Data.Image exposing (..)

import App.View.Image

Success

This passes because we've only forbidden modules in App.Data to import from App.View, not the other way around.

module App.View.Image exposing (..)

import App.Data.Image

When (not) to enable this rule

This rule is useful when you have set up a namespace structure where you want your module dependencies to form a directed acyclic graph.